mirror of
https://github.com/agdamsbo/REDCapCAST.git
synced 2024-11-22 13:30:23 +01:00
Improved instructions for R package in README.md.
This commit is contained in:
parent
2cf5c8e019
commit
a1297903c2
53
README.md
53
README.md
@ -35,6 +35,8 @@ a solution to handle the problem in both SAS and R.
|
|||||||
## Instructions
|
## Instructions
|
||||||
### R
|
### R
|
||||||
|
|
||||||
|
#### Installation
|
||||||
|
|
||||||
First you must install the package. To do so, execute the following in your R console:
|
First you must install the package. To do so, execute the following in your R console:
|
||||||
|
|
||||||
```r
|
```r
|
||||||
@ -42,14 +44,57 @@ if (!require(devtools)) install.packages("devtools")
|
|||||||
devtools::install_github("SpectrumHealthResearch/REDCapRITS/R")
|
devtools::install_github("SpectrumHealthResearch/REDCapRITS/R")
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Usage
|
||||||
|
|
||||||
After the package is installed, follow these instructions:
|
After the package is installed, follow these instructions:
|
||||||
|
|
||||||
1. Download the record dataset and metadata. This can
|
1. Download the record dataset and metadata. This can
|
||||||
be accomplished either by traditional methods or using the API. The
|
be accomplished either by traditional methods or using the API.
|
||||||
`read.csv()` function should be able to handle newline characters within
|
|
||||||
records, so no pre-processing of metadata csv is needed.
|
|
||||||
1. Call the function, pointing it to your record dataset and metadata
|
1. Call the function, pointing it to your record dataset and metadata
|
||||||
`data.frame`s or JSON character vectors.
|
`data.frame`s or JSON character vectors. You may need to load the package via
|
||||||
|
`library()` or `require()`.
|
||||||
|
|
||||||
|
#### Examples
|
||||||
|
|
||||||
|
Here is an example usage in conjuction with an API call to your REDCap instance:
|
||||||
|
|
||||||
|
```r
|
||||||
|
library(RCurl)
|
||||||
|
|
||||||
|
# Get the records
|
||||||
|
records <- postForm(
|
||||||
|
uri = api_url, # Supply your site-specific URI
|
||||||
|
token = api_token, # Supply your own API token
|
||||||
|
content = 'record',
|
||||||
|
format = 'json',
|
||||||
|
returnFormat = 'json'
|
||||||
|
)
|
||||||
|
|
||||||
|
# Get the metadata
|
||||||
|
metadata <- postForm(
|
||||||
|
uri = api_url,
|
||||||
|
token = api_token,
|
||||||
|
content = 'metadata',
|
||||||
|
format = 'json'
|
||||||
|
)
|
||||||
|
|
||||||
|
# Convert exported JSON strings into a list of data.frames
|
||||||
|
REDCapRITS::REDCap_split(records, metadata)
|
||||||
|
```
|
||||||
|
|
||||||
|
And here is an example of usage when downloading a REDCap export manually from your REDCap web interface:
|
||||||
|
|
||||||
|
```r
|
||||||
|
# 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)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
### SAS
|
### SAS
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user