read_prospect: Read Prospect Exports

Description Usage Arguments Details Value Examples

Description

Read in the raw CSV files exported from Prospect.

Usage

1
2
read_prospect(file = "Lookups.csv", header = TRUE, sep = ",",
  convert.dates = TRUE, dictionary = data.dictionary, ...)

Arguments

file

File to read in.

header

Header option (default TRUE shouldn't need changing).

sep

Seperator used (default , (comma) shouldn't need changing).

dictionary

Dictionary object.

dates

A list of character strings to use as regular expressions to identify date. variables that need converting from character to string.

Details

Case Report Forms are stored in the Prospect Database (https://www.ctru-prospect.shef.ac.uk/) and are exported as CSV files. These need reading into R for linking because the relational structure that exists within Prospect is lost on export prior to analysis.

When using this function the _first_ file that should be converted is 'Lookups.csv' as this is the dictionary file that can be used to automatically encode all factor variables across all subsequent files.

Value

Data frame containing the specified file with dates converted to POSIX and factors converted to with labels applied to them.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
## Read in the 'Lookups.csv' which is the data dictionary for all factor variables
data.dictionary <- read_prospect(file          = 'Lookups.csv',
                                 header        = TRUE,
                                 sep           = ',',
                                 convert.dates = FALSE,
                                 dictionary    = NULL)

## Now use the data dictionary to encode factor variables and convert dates
screening <- read_prospect(file          = 'Screening.csv',
                           header        = TRUE,
                           sep           = ',',
                           convert.dates = TRUE,
                           dictionary    = data.dictionary)

## You can use lapply() to read in all files in a given directory
lapply(x        = list.files(pattern = ".csv"),
       function = read_prospect(file          = x,
                                header        = TRUE,
                                sep           = ',',
                                convert.dates = TRUE,
                                dictionary    = data.dictionary)

ns-ctru/ctru documentation built on May 23, 2019, 9:34 p.m.