r-pkg: updating rd file with examples

This commit is contained in:
pegeler 2018-06-08 23:47:34 -04:00
parent d20a3625f3
commit 275851f26e

View File

@ -25,6 +25,8 @@ is used to determine which fields should be included in each resultant table.
} }
\examples{ \examples{
\dontrun{ \dontrun{
# Using an API call -------------------------------------------------------
library(RCurl) library(RCurl)
# Get the records # Get the records
@ -38,14 +40,41 @@ records <- postForm(
# Get the metadata # Get the metadata
metadata <- postForm( metadata <- postForm(
uri = api_url, uri = api_url, # Supply your site-specific URI
token = api_token, token = api_token, # Supply your own API token
content = 'metadata', content = 'metadata',
format = 'json' format = 'json'
) )
# Convert exported JSON strings into a list of data.frames # Convert exported JSON strings into a list of data.frames
REDCap_split(records, metadata) REDCapRITS::REDCap_split(records, metadata)
# Using a raw data export -------------------------------------------------
# Get the records
records <- read.csv("/path/to/data/ExampleProject_DATA_2018-06-03_1700.csv")
# Get the metadata
metadata <- read.csv("/path/to/data/ExampleProject_DataDictionary_2018-06-03.csv")
# Split the tables
REDCapRITS::REDCap_split(records, metadata)
# In conjunction with the R export script ---------------------------------
# You must set the working directory first since the REDCap data export script
# contains relative file references.
setwd("/path/to/data/")
# Run the data export script supplied by REDCap.
# This will create a data.frame of your records called 'data'
source("ExampleProject_R_2018-06-03_1700.r")
# Get the metadata
metadata <- read.csv("ExampleProject_DataDictionary_2018-06-03.csv")
# Split the tables
REDCapRITS::REDCap_split(data, metadata)
} }
} }
\author{ \author{