mirror of
https://github.com/agdamsbo/REDCapCAST.git
synced 2026-06-19 13:17:30 +02:00
trying to overcome error messagein github actions by moving R package to root.
This commit is contained in:
parent
58cabc7153
commit
582a481942
33 changed files with 1 additions and 1276 deletions
|
|
@ -1,5 +0,0 @@
|
|||
^.*\.Rproj$
|
||||
^\.Rproj\.user$
|
||||
^\.travis\.yml$
|
||||
^appveyor\.yml$
|
||||
^data-raw$
|
||||
3
R/.gitignore
vendored
3
R/.gitignore
vendored
|
|
@ -1,3 +0,0 @@
|
|||
.Rproj.user
|
||||
.Rhistory
|
||||
.RData
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
Package: REDCapRITS
|
||||
Title: REDCap Repeating Instrument Table Splitter
|
||||
Version: 0.2.2.1
|
||||
Authors@R: c(
|
||||
person("Paul", "Egeler", email = "paul.egeler@spectrumhealth.org", role = c("aut", "cre")),
|
||||
person("Spectrum Health, Grand Rapids, MI", role = "cph"),
|
||||
person("Andreas Gammelgaard", "Damsbo", , "agdamsbo@clin.au.dk", role = c("ctb"),
|
||||
comment = c(ORCID = "0000-0002-7559-1154")))
|
||||
Copyright: Spectrum Health, Grand Rapids, MI
|
||||
Description: Split REDCap repeating instruments output into multiple tables.
|
||||
This will take raw output from a REDCap export and split it into a base table
|
||||
and child tables for each repeating instrument.
|
||||
REDCap (Research Electronic Data Capture) is a secure, web-based software
|
||||
platform designed to support data capture for research studies, providing
|
||||
1) an intuitive interface for validated data capture; 2) audit trails for
|
||||
tracking data manipulation and export procedures; 3) automated export
|
||||
procedures for seamless data downloads to common statistical packages; and
|
||||
4) procedures for data integration and interoperability with external sources
|
||||
(<doi:10.1016/j.jbi.2008.08.010>; <doi:10.1016/j.jbi.2019.103208>).
|
||||
Depends: R (>= 3.4.0)
|
||||
Suggests:
|
||||
RCurl,
|
||||
httr,
|
||||
jsonlite,
|
||||
testthat,
|
||||
Hmisc,
|
||||
readr
|
||||
License: GPL-3
|
||||
Encoding: UTF-8
|
||||
LazyData: true
|
||||
RoxygenNote: 7.2.3
|
||||
URL: https://github.com/SpectrumHealthResearch/REDCapRITS
|
||||
BugReports: https://github.com/SpectrumHealthResearch/REDCapRITS/issues
|
||||
Collate:
|
||||
'utils.r'
|
||||
'process_user_input.r'
|
||||
'REDCap_split.r'
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
# Generated by roxygen2: do not edit by hand
|
||||
|
||||
export(REDCap_split)
|
||||
19
R/NEWS.md
19
R/NEWS.md
|
|
@ -1,19 +0,0 @@
|
|||
# REDCapRITS 0.2.1 (Release date: 2019-07-26)
|
||||
|
||||
* [bug] Can now accept `"tbl_df"` objects and `NA`s in the `redcap_repeat_instrument` field. (#12)
|
||||
|
||||
# REDCapRITS 0.2.0 (Release date: 2019-07-08)
|
||||
|
||||
* [feature] User can now separate each form into its own data.frame, regardless if it is a repeating instrument or not. (#10)
|
||||
* [bug] Handles auto-generated form timestamp fields.
|
||||
|
||||
# REDCapRITS 0.1.0 (Release date: 2019-07-01)
|
||||
|
||||
* [feature] User can now specify the name of the 'primary' table, which previously was left blank. (#9)
|
||||
* [bug] Keeps REDCap-generated fields in non-repeating data.frame that are not present in metadata file. (#7)
|
||||
* [enhancement] Unit tests created. (#6)
|
||||
* [bug] Checkbox data now supported. (#1)
|
||||
|
||||
# REDCapRITS 0.0.0 (Release date: 2018-06-03)
|
||||
|
||||
* Initial Release
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
Version: 1.0
|
||||
|
||||
RestoreWorkspace: No
|
||||
SaveWorkspace: No
|
||||
AlwaysSaveHistory: Default
|
||||
|
||||
EnableCodeIndexing: Yes
|
||||
UseSpacesForTab: Yes
|
||||
NumSpacesForTab: 2
|
||||
Encoding: UTF-8
|
||||
|
||||
RnwWeave: Sweave
|
||||
LaTeX: pdfLaTeX
|
||||
|
||||
AutoAppendNewline: Yes
|
||||
StripTrailingWhitespace: Yes
|
||||
|
||||
BuildType: Package
|
||||
PackageUseDevtools: Yes
|
||||
PackageInstallArgs: --no-multiarch --with-keep.source
|
||||
PackageRoxygenize: rd,collate,namespace
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
metadata_names <- c(
|
||||
"field_name", "form_name", "section_header", "field_type",
|
||||
"field_label", "select_choices_or_calculations", "field_note",
|
||||
"text_validation_type_or_show_slider_number", "text_validation_min",
|
||||
"text_validation_max", "identifier", "branching_logic", "required_field",
|
||||
"custom_alignment", "question_number", "matrix_group_name", "matrix_ranking",
|
||||
"field_annotation"
|
||||
)
|
||||
|
||||
usethis::use_data(metadata_names, overwrite = TRUE, internal = TRUE)
|
||||
|
|
@ -1,101 +0,0 @@
|
|||
% Generated by roxygen2: do not edit by hand
|
||||
% Please edit documentation in R/REDCap_split.r
|
||||
\name{REDCap_split}
|
||||
\alias{REDCap_split}
|
||||
\title{Split REDCap repeating instruments table into multiple tables}
|
||||
\usage{
|
||||
REDCap_split(
|
||||
records,
|
||||
metadata,
|
||||
primary_table_name = "",
|
||||
forms = c("repeating", "all")
|
||||
)
|
||||
}
|
||||
\arguments{
|
||||
\item{records}{Exported project records. May be a \code{data.frame},
|
||||
\code{response}, or \code{character} vector containing JSON from an API
|
||||
call.}
|
||||
|
||||
\item{metadata}{Project metadata (the data dictionary). May be a
|
||||
\code{data.frame}, \code{response}, or \code{character} vector containing
|
||||
JSON from an API call.}
|
||||
|
||||
\item{primary_table_name}{Name given to the list element for the primary
|
||||
output table (as described in \emph{README.md}). Ignored if
|
||||
\code{forms = 'all'}.}
|
||||
|
||||
\item{forms}{Indicate whether to create separate tables for repeating
|
||||
instruments only or for all forms.}
|
||||
}
|
||||
\value{
|
||||
A list of \code{"data.frame"}s. The number of tables will differ
|
||||
depending on the \code{forms} option selected.
|
||||
\itemize{
|
||||
\item \code{'repeating'}: one base table and one or more
|
||||
tables for each repeating instrument.
|
||||
\item \code{'all'}: a data.frame for each instrument, regardless of
|
||||
whether it is a repeating instrument or not.
|
||||
}
|
||||
}
|
||||
\description{
|
||||
This will take output from a REDCap export and split it into a base table
|
||||
and child tables for each repeating instrument. Metadata
|
||||
is used to determine which fields should be included in each resultant table.
|
||||
}
|
||||
\examples{
|
||||
\dontrun{
|
||||
# Using an API call -------------------------------------------------------
|
||||
|
||||
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, # Supply your site-specific URI
|
||||
token = api_token, # Supply your own API token
|
||||
content = 'metadata',
|
||||
format = 'json'
|
||||
)
|
||||
|
||||
# Convert exported JSON strings into a list of data.frames
|
||||
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{
|
||||
Paul W. Egeler, M.S., GStat
|
||||
}
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
library(testthat)
|
||||
library(REDCapRITS)
|
||||
|
||||
test_check("REDCapRITS")
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
row,redcap_repeat_instrument,redcap_repeat_instance,mpg,cyl,disp,hp,drat,wt,qsec,vs,am,gear,carb,color_available___red,color_available___green,color_available___blue,color_available___black,motor_trend_cars_complete,letter_group___a,letter_group___b,letter_group___c,choice,grouping_complete,price,color,customer,sale_complete
|
||||
"AMC Javelin",,,15.2,8,304,150,3.15,3.435,17.3,0,0,3,2,1,1,1,0,1,1,1,0,choice2,2,,,,
|
||||
"AMC Javelin",sale,1,,,,,,,,,,,,,,,,,,,,,,12000.50,1,Bob,0
|
||||
"AMC Javelin",sale,2,,,,,,,,,,,,,,,,,,,,,,13750.77,3,Sue,2
|
||||
"AMC Javelin",sale,3,,,,,,,,,,,,,,,,,,,,,,15004.57,2,Kim,0
|
||||
"Cadillac Fleetwood",,,10.4,8,472,205,2.93,5.25,17.98,0,0,3,4,0,0,0,0,0,0,0,0,,0,,,,
|
||||
"Camaro Z28",,,13.3,8,350,245,3.73,3.84,15.41,0,0,3,4,0,0,0,0,0,1,0,1,choice1,2,,,,
|
||||
"Camaro Z28",sale,1,,,,,,,,,,,,,,,,,,,,,,7800.00,2,Janice,2
|
||||
"Camaro Z28",sale,2,,,,,,,,,,,,,,,,,,,,,,8000.00,3,Tim,0
|
||||
"Chrysler Imperial",,,14.7,8,440,230,3.23,5.345,17.42,0,0,3,4,0,0,0,0,0,0,1,1,choice1,2,,,,
|
||||
"Chrysler Imperial",sale,1,,,,,,,,,,,,,,,,,,,,,,7500.00,1,Jim,2
|
||||
"Datsun 710",,,22.8,4,108,93,3.85,2.32,18.61,1,1,4,1,0,0,0,0,0,0,1,1,,0,,,,
|
||||
"Dodge Challenger",,,15.5,8,318,150,2.76,3.52,16.87,0,0,3,2,0,0,0,0,0,0,0,0,,0,,,,
|
||||
"Duster 360",,,14.3,8,360,245,3.21,3.57,15.84,0,0,3,4,0,0,0,0,0,0,1,1,choice1,1,,,,
|
||||
"Duster 360",sale,1,,,,,,,,,,,,,,,,,,,,,,8756.40,4,Sarah,1
|
||||
"Duster 360",sale,2,,,,,,,,,,,,,,,,,,,,,,6800.88,2,Pablo,0
|
||||
"Duster 360",sale,3,,,,,,,,,,,,,,,,,,,,,,8888.88,1,Erica,0
|
||||
"Duster 360",sale,4,,,,,,,,,,,,,,,,,,,,,,970.00,4,Juan,0
|
||||
"Ferrari Dino",,,19.7,6,145,175,3.62,2.77,15.5,0,1,5,6,0,0,0,0,0,0,0,0,,0,,,,
|
||||
"Fiat 128",,,32.4,4,78.7,66,4.08,2.2,19.47,1,1,4,1,0,0,0,0,0,0,0,0,,0,,,,
|
||||
"Fiat X1-9",,,27.3,4,79,66,4.08,1.935,18.9,1,1,4,1,0,0,0,0,0,0,0,0,,0,,,,
|
||||
"Ford Pantera L",,,15.8,8,351,264,4.22,3.17,14.5,0,1,5,4,0,0,0,0,0,0,0,0,,0,,,,
|
||||
"Honda Civic",,,30.4,4,75.7,52,4.93,1.615,18.52,1,1,4,2,0,0,0,0,0,0,0,0,,0,,,,
|
||||
"Hornet 4 Drive",,,21.4,6,258,110,3.08,3.215,19.44,1,0,3,1,0,0,0,0,0,0,0,0,,0,,,,
|
||||
"Hornet Sportabout",,,18.7,8,360,175,3.15,3.44,17.02,0,0,3,2,0,0,0,0,0,0,0,0,,0,,,,
|
||||
"Lincoln Continental",,,10.4,8,460,215,3,5.424,17.82,0,0,3,4,0,0,0,0,0,0,0,0,,0,,,,
|
||||
"Lotus Europa",,,30.4,4,95.1,113,3.77,1.513,16.9,1,1,5,2,0,0,0,0,0,0,0,0,,0,,,,
|
||||
"Maserati Bora",,,15,8,301,335,3.54,3.57,14.6,0,1,5,8,0,0,0,0,0,0,0,0,,0,,,,
|
||||
"Mazda RX4",,,21,6,160,110,3.9,2.62,16.46,0,1,4,4,0,0,0,0,0,0,0,0,,0,,,,
|
||||
"Mazda RX4 Wag",,,21,6,160,110,3.9,2.875,17.02,0,1,4,4,0,0,0,0,0,1,1,0,,0,,,,
|
||||
"Merc 230",,,22.8,4,140.8,95,3.92,3.15,22.9,1,0,4,2,0,0,0,0,0,1,1,0,choice2,0,,,,
|
||||
"Merc 230",sale,1,,,,,,,,,,,,,,,,,,,,,,7800.98,2,Ted,0
|
||||
"Merc 230",sale,2,,,,,,,,,,,,,,,,,,,,,,7954.00,1,Quentin,0
|
||||
"Merc 230",sale,3,,,,,,,,,,,,,,,,,,,,,,6800.55,3,Sharon,2
|
||||
"Merc 240D",,,24.4,4,146.7,62,3.69,3.19,20,1,0,4,2,0,0,0,0,0,0,0,0,,0,,,,
|
||||
"Merc 280",,,19.2,6,167.6,123,3.92,3.44,18.3,1,0,4,4,0,0,0,0,0,0,0,0,,0,,,,
|
||||
"Merc 280C",,,17.8,6,167.6,123,3.92,3.44,18.9,1,0,4,4,0,0,0,0,0,0,0,0,,0,,,,
|
||||
"Merc 450SE",,,16.4,8,275.8,180,3.07,4.07,17.4,0,0,3,3,0,0,0,0,0,0,0,0,,0,,,,
|
||||
"Merc 450SL",,,17.3,8,275.8,180,3.07,3.73,17.6,0,0,3,3,0,0,0,0,0,0,0,0,,0,,,,
|
||||
"Merc 450SLC",,,15.2,8,275.8,180,3.07,3.78,18,0,0,3,3,0,0,0,0,0,0,0,0,,0,,,,
|
||||
"Pontiac Firebird",,,19.2,8,400,175,3.08,3.845,17.05,0,0,3,2,0,0,0,0,0,0,0,0,,0,,,,
|
||||
"Porsche 914-2",,,26,4,120.3,91,4.43,2.14,16.7,0,1,5,2,0,0,0,0,0,0,0,0,,0,,,,
|
||||
"Toyota Corolla",,,33.9,4,71.1,65,4.22,1.835,19.9,1,1,4,1,0,0,0,0,0,0,0,0,,0,,,,
|
||||
"Toyota Corona",,,21.5,4,120.1,97,3.7,2.465,20.01,1,0,3,1,0,0,0,0,0,0,0,0,,0,,,,
|
||||
Valiant,,,18.1,6,225,105,2.76,3.46,20.22,1,0,3,1,0,0,0,0,0,0,0,0,,0,,,,
|
||||
"Volvo 142E",,,21.4,4,121,109,4.11,2.78,18.6,1,1,4,2,0,0,0,0,0,0,0,0,,0,,,,
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
"Variable / Field Name","Form Name","Section Header","Field Type","Field Label","Choices, Calculations, OR Slider Labels","Field Note","Text Validation Type OR Show Slider Number","Text Validation Min","Text Validation Max",Identifier?,"Branching Logic (Show field only if...)","Required Field?","Custom Alignment","Question Number (surveys only)","Matrix Group Name","Matrix Ranking?","Field Annotation"
|
||||
row,motor_trend_cars,,text,Name,,,,,,,,,,,,,
|
||||
mpg,motor_trend_cars,,text,"Miles/(US) gallon",,,number,,,,,,,,,,
|
||||
cyl,motor_trend_cars,,radio,"Number of cylinders","3, 3 | 4, 4 | 5, 5 | 6, 6 | 7, 7 | 8, 8",,,,,,,,,,,,
|
||||
disp,motor_trend_cars,,text,Displacement,,(cu.in.),number,,,,,,,,,,
|
||||
hp,motor_trend_cars,,text,"Gross horsepower",,,number,,,,,,,,,,
|
||||
drat,motor_trend_cars,,text,"Rear axle ratio",,,number,,,,,,,,,,
|
||||
wt,motor_trend_cars,,text,Weight,,"(1000 lbs)",number,,,,,,,,,,
|
||||
qsec,motor_trend_cars,,text,"1/4 mile time",,,number,,,,,,,,,,
|
||||
vs,motor_trend_cars,,yesno,"V engine?",,,,,,,,,,,,,
|
||||
am,motor_trend_cars,,dropdown,Transmission,"0, Automatic | 1, Manual"," (0 = automatic, 1 = manual)",,,,,,,,,,,
|
||||
gear,motor_trend_cars,,radio,"Number of forward gears","3, 3 | 4, 4 | 5, 5",,,,,,,,,,,,
|
||||
carb,motor_trend_cars,,radio,"Number of carburetors","1, 1 | 2, 2 | 3, 3 | 4, 4 | 5, 5 | 6, 6 | 7, 7 | 8, 8",,,,,,,,,,,,
|
||||
color_available,motor_trend_cars,,checkbox,"Colors Available","red, Red | green, Green | blue, Blue | black, Black",,,,,,,,,,,,
|
||||
letter_group,grouping,,checkbox,"Which group?","a, A | b, B | c, C",,,,,,,,,,,,
|
||||
choice,grouping,,radio,"Choose one","choice1, Choice 1 | choice2, Choice 2",,,,,,,,,,,,
|
||||
price,sale,,text,"Sale price",,,number_2dp,,,,,,,,,,
|
||||
color,sale,,dropdown,Color,"1, red | 2, green | 3, blue | 4, black",,,,,,,,,,,,
|
||||
customer,sale,,text,"Customer Name",,,,,,,,,RH,,,,
|
||||
|
|
|
@ -1,362 +0,0 @@
|
|||
[
|
||||
{
|
||||
"field_name": "row",
|
||||
"form_name": "motor_trend_cars",
|
||||
"section_header": "",
|
||||
"field_type": "text",
|
||||
"field_label": "Name",
|
||||
"select_choices_or_calculations": "",
|
||||
"field_note": "",
|
||||
"text_validation_type_or_show_slider_number": "",
|
||||
"text_validation_min": "",
|
||||
"text_validation_max": "",
|
||||
"identifier": "",
|
||||
"branching_logic": "",
|
||||
"required_field": "",
|
||||
"custom_alignment": "",
|
||||
"question_number": "",
|
||||
"matrix_group_name": "",
|
||||
"matrix_ranking": "",
|
||||
"field_annotation": ""
|
||||
},
|
||||
{
|
||||
"field_name": "mpg",
|
||||
"form_name": "motor_trend_cars",
|
||||
"section_header": "",
|
||||
"field_type": "text",
|
||||
"field_label": "Miles/(US) gallon",
|
||||
"select_choices_or_calculations": "",
|
||||
"field_note": "",
|
||||
"text_validation_type_or_show_slider_number": "number",
|
||||
"text_validation_min": "",
|
||||
"text_validation_max": "",
|
||||
"identifier": "",
|
||||
"branching_logic": "",
|
||||
"required_field": "",
|
||||
"custom_alignment": "",
|
||||
"question_number": "",
|
||||
"matrix_group_name": "",
|
||||
"matrix_ranking": "",
|
||||
"field_annotation": ""
|
||||
},
|
||||
{
|
||||
"field_name": "cyl",
|
||||
"form_name": "motor_trend_cars",
|
||||
"section_header": "",
|
||||
"field_type": "radio",
|
||||
"field_label": "Number of cylinders",
|
||||
"select_choices_or_calculations": "3, 3 | 4, 4 | 5, 5 | 6, 6 | 7, 7 | 8, 8",
|
||||
"field_note": "",
|
||||
"text_validation_type_or_show_slider_number": "",
|
||||
"text_validation_min": "",
|
||||
"text_validation_max": "",
|
||||
"identifier": "",
|
||||
"branching_logic": "",
|
||||
"required_field": "",
|
||||
"custom_alignment": "",
|
||||
"question_number": "",
|
||||
"matrix_group_name": "",
|
||||
"matrix_ranking": "",
|
||||
"field_annotation": ""
|
||||
},
|
||||
{
|
||||
"field_name": "disp",
|
||||
"form_name": "motor_trend_cars",
|
||||
"section_header": "",
|
||||
"field_type": "text",
|
||||
"field_label": "Displacement",
|
||||
"select_choices_or_calculations": "",
|
||||
"field_note": "(cu.in.)",
|
||||
"text_validation_type_or_show_slider_number": "number",
|
||||
"text_validation_min": "",
|
||||
"text_validation_max": "",
|
||||
"identifier": "",
|
||||
"branching_logic": "",
|
||||
"required_field": "",
|
||||
"custom_alignment": "",
|
||||
"question_number": "",
|
||||
"matrix_group_name": "",
|
||||
"matrix_ranking": "",
|
||||
"field_annotation": ""
|
||||
},
|
||||
{
|
||||
"field_name": "hp",
|
||||
"form_name": "motor_trend_cars",
|
||||
"section_header": "",
|
||||
"field_type": "text",
|
||||
"field_label": "Gross horsepower",
|
||||
"select_choices_or_calculations": "",
|
||||
"field_note": "",
|
||||
"text_validation_type_or_show_slider_number": "number",
|
||||
"text_validation_min": "",
|
||||
"text_validation_max": "",
|
||||
"identifier": "",
|
||||
"branching_logic": "",
|
||||
"required_field": "",
|
||||
"custom_alignment": "",
|
||||
"question_number": "",
|
||||
"matrix_group_name": "",
|
||||
"matrix_ranking": "",
|
||||
"field_annotation": ""
|
||||
},
|
||||
{
|
||||
"field_name": "drat",
|
||||
"form_name": "motor_trend_cars",
|
||||
"section_header": "",
|
||||
"field_type": "text",
|
||||
"field_label": "Rear axle ratio",
|
||||
"select_choices_or_calculations": "",
|
||||
"field_note": "",
|
||||
"text_validation_type_or_show_slider_number": "number",
|
||||
"text_validation_min": "",
|
||||
"text_validation_max": "",
|
||||
"identifier": "",
|
||||
"branching_logic": "",
|
||||
"required_field": "",
|
||||
"custom_alignment": "",
|
||||
"question_number": "",
|
||||
"matrix_group_name": "",
|
||||
"matrix_ranking": "",
|
||||
"field_annotation": ""
|
||||
},
|
||||
{
|
||||
"field_name": "wt",
|
||||
"form_name": "motor_trend_cars",
|
||||
"section_header": "",
|
||||
"field_type": "text",
|
||||
"field_label": "Weight",
|
||||
"select_choices_or_calculations": "",
|
||||
"field_note": "(1000 lbs)",
|
||||
"text_validation_type_or_show_slider_number": "number",
|
||||
"text_validation_min": "",
|
||||
"text_validation_max": "",
|
||||
"identifier": "",
|
||||
"branching_logic": "",
|
||||
"required_field": "",
|
||||
"custom_alignment": "",
|
||||
"question_number": "",
|
||||
"matrix_group_name": "",
|
||||
"matrix_ranking": "",
|
||||
"field_annotation": ""
|
||||
},
|
||||
{
|
||||
"field_name": "qsec",
|
||||
"form_name": "motor_trend_cars",
|
||||
"section_header": "",
|
||||
"field_type": "text",
|
||||
"field_label": "1/4 mile time",
|
||||
"select_choices_or_calculations": "",
|
||||
"field_note": "",
|
||||
"text_validation_type_or_show_slider_number": "number",
|
||||
"text_validation_min": "",
|
||||
"text_validation_max": "",
|
||||
"identifier": "",
|
||||
"branching_logic": "",
|
||||
"required_field": "",
|
||||
"custom_alignment": "",
|
||||
"question_number": "",
|
||||
"matrix_group_name": "",
|
||||
"matrix_ranking": "",
|
||||
"field_annotation": ""
|
||||
},
|
||||
{
|
||||
"field_name": "vs",
|
||||
"form_name": "motor_trend_cars",
|
||||
"section_header": "",
|
||||
"field_type": "yesno",
|
||||
"field_label": "V engine?",
|
||||
"select_choices_or_calculations": "",
|
||||
"field_note": "",
|
||||
"text_validation_type_or_show_slider_number": "",
|
||||
"text_validation_min": "",
|
||||
"text_validation_max": "",
|
||||
"identifier": "",
|
||||
"branching_logic": "",
|
||||
"required_field": "",
|
||||
"custom_alignment": "",
|
||||
"question_number": "",
|
||||
"matrix_group_name": "",
|
||||
"matrix_ranking": "",
|
||||
"field_annotation": ""
|
||||
},
|
||||
{
|
||||
"field_name": "am",
|
||||
"form_name": "motor_trend_cars",
|
||||
"section_header": "",
|
||||
"field_type": "dropdown",
|
||||
"field_label": "Transmission",
|
||||
"select_choices_or_calculations": "0, Automatic | 1, Manual",
|
||||
"field_note": " (0 = automatic, 1 = manual)",
|
||||
"text_validation_type_or_show_slider_number": "",
|
||||
"text_validation_min": "",
|
||||
"text_validation_max": "",
|
||||
"identifier": "",
|
||||
"branching_logic": "",
|
||||
"required_field": "",
|
||||
"custom_alignment": "",
|
||||
"question_number": "",
|
||||
"matrix_group_name": "",
|
||||
"matrix_ranking": "",
|
||||
"field_annotation": ""
|
||||
},
|
||||
{
|
||||
"field_name": "gear",
|
||||
"form_name": "motor_trend_cars",
|
||||
"section_header": "",
|
||||
"field_type": "radio",
|
||||
"field_label": "Number of forward gears",
|
||||
"select_choices_or_calculations": "3, 3 | 4, 4 | 5, 5",
|
||||
"field_note": "",
|
||||
"text_validation_type_or_show_slider_number": "",
|
||||
"text_validation_min": "",
|
||||
"text_validation_max": "",
|
||||
"identifier": "",
|
||||
"branching_logic": "",
|
||||
"required_field": "",
|
||||
"custom_alignment": "",
|
||||
"question_number": "",
|
||||
"matrix_group_name": "",
|
||||
"matrix_ranking": "",
|
||||
"field_annotation": ""
|
||||
},
|
||||
{
|
||||
"field_name": "carb",
|
||||
"form_name": "motor_trend_cars",
|
||||
"section_header": "",
|
||||
"field_type": "radio",
|
||||
"field_label": "Number of carburetors",
|
||||
"select_choices_or_calculations": "1, 1 | 2, 2 | 3, 3 | 4, 4 | 5, 5 | 6, 6 | 7, 7 | 8, 8",
|
||||
"field_note": "",
|
||||
"text_validation_type_or_show_slider_number": "",
|
||||
"text_validation_min": "",
|
||||
"text_validation_max": "",
|
||||
"identifier": "",
|
||||
"branching_logic": "",
|
||||
"required_field": "",
|
||||
"custom_alignment": "",
|
||||
"question_number": "",
|
||||
"matrix_group_name": "",
|
||||
"matrix_ranking": "",
|
||||
"field_annotation": ""
|
||||
},
|
||||
{
|
||||
"field_name": "color_available",
|
||||
"form_name": "motor_trend_cars",
|
||||
"section_header": "",
|
||||
"field_type": "checkbox",
|
||||
"field_label": "Colors Available",
|
||||
"select_choices_or_calculations": "red, Red | green, Green | blue, Blue | black, Black",
|
||||
"field_note": "",
|
||||
"text_validation_type_or_show_slider_number": "",
|
||||
"text_validation_min": "",
|
||||
"text_validation_max": "",
|
||||
"identifier": "",
|
||||
"branching_logic": "",
|
||||
"required_field": "",
|
||||
"custom_alignment": "",
|
||||
"question_number": "",
|
||||
"matrix_group_name": "",
|
||||
"matrix_ranking": "",
|
||||
"field_annotation": ""
|
||||
},
|
||||
{
|
||||
"field_name": "letter_group",
|
||||
"form_name": "grouping",
|
||||
"section_header": "",
|
||||
"field_type": "checkbox",
|
||||
"field_label": "Which group?",
|
||||
"select_choices_or_calculations": "a, A | b, B | c, C",
|
||||
"field_note": "",
|
||||
"text_validation_type_or_show_slider_number": "",
|
||||
"text_validation_min": "",
|
||||
"text_validation_max": "",
|
||||
"identifier": "",
|
||||
"branching_logic": "",
|
||||
"required_field": "",
|
||||
"custom_alignment": "",
|
||||
"question_number": "",
|
||||
"matrix_group_name": "",
|
||||
"matrix_ranking": "",
|
||||
"field_annotation": ""
|
||||
},
|
||||
{
|
||||
"field_name": "choice",
|
||||
"form_name": "grouping",
|
||||
"section_header": "",
|
||||
"field_type": "radio",
|
||||
"field_label": "Choose one",
|
||||
"select_choices_or_calculations": "choice1, Choice 1 | choice2, Choice 2",
|
||||
"field_note": "",
|
||||
"text_validation_type_or_show_slider_number": "",
|
||||
"text_validation_min": "",
|
||||
"text_validation_max": "",
|
||||
"identifier": "",
|
||||
"branching_logic": "",
|
||||
"required_field": "",
|
||||
"custom_alignment": "",
|
||||
"question_number": "",
|
||||
"matrix_group_name": "",
|
||||
"matrix_ranking": "",
|
||||
"field_annotation": ""
|
||||
},
|
||||
{
|
||||
"field_name": "price",
|
||||
"form_name": "sale",
|
||||
"section_header": "",
|
||||
"field_type": "text",
|
||||
"field_label": "Sale price",
|
||||
"select_choices_or_calculations": "",
|
||||
"field_note": "",
|
||||
"text_validation_type_or_show_slider_number": "number_2dp",
|
||||
"text_validation_min": "",
|
||||
"text_validation_max": "",
|
||||
"identifier": "",
|
||||
"branching_logic": "",
|
||||
"required_field": "",
|
||||
"custom_alignment": "",
|
||||
"question_number": "",
|
||||
"matrix_group_name": "",
|
||||
"matrix_ranking": "",
|
||||
"field_annotation": ""
|
||||
},
|
||||
{
|
||||
"field_name": "color",
|
||||
"form_name": "sale",
|
||||
"section_header": "",
|
||||
"field_type": "dropdown",
|
||||
"field_label": "Color",
|
||||
"select_choices_or_calculations": "1, red | 2, green | 3, blue | 4, black",
|
||||
"field_note": "",
|
||||
"text_validation_type_or_show_slider_number": "",
|
||||
"text_validation_min": "",
|
||||
"text_validation_max": "",
|
||||
"identifier": "",
|
||||
"branching_logic": "",
|
||||
"required_field": "",
|
||||
"custom_alignment": "",
|
||||
"question_number": "",
|
||||
"matrix_group_name": "",
|
||||
"matrix_ranking": "",
|
||||
"field_annotation": ""
|
||||
},
|
||||
{
|
||||
"field_name": "customer",
|
||||
"form_name": "sale",
|
||||
"section_header": "",
|
||||
"field_type": "text",
|
||||
"field_label": "Customer Name",
|
||||
"select_choices_or_calculations": "",
|
||||
"field_note": "",
|
||||
"text_validation_type_or_show_slider_number": "",
|
||||
"text_validation_min": "",
|
||||
"text_validation_max": "",
|
||||
"identifier": "",
|
||||
"branching_logic": "",
|
||||
"required_field": "",
|
||||
"custom_alignment": "RH",
|
||||
"question_number": "",
|
||||
"matrix_group_name": "",
|
||||
"matrix_ranking": "",
|
||||
"field_annotation": ""
|
||||
}
|
||||
]
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,11 +0,0 @@
|
|||
record_id,redcap_event_name,redcap_repeat_instrument,redcap_repeat_instance,redcap_data_access_group,redcap_survey_identifier,informed_consent_and_addendum_timestamp,icf_first_name,icf_last_name,icf_date,icf_sign,icf_consenter_name,icf_consentee_info,icf_consentee_sign,icf_consentee_date,informed_consent_and_addendum_complete,signed_consent_1,signed_consent_2,signed_consent_3,signed_addendum1,signed_addendum2,signed_addendum3,upload_of_signed_icfs_complete,demo_date,demo_name_first,demo_name_init,demo_name_last,demo_date_birth,demo_street_ad,demo_city_ad,demo_state_ad,demo_zip,demo_daytime,demo_email,demo_ethnic,demo_racial,demo_racial_oth,demo_military_mrn,demo_ssn,demographics_complete,elig_icf,elig_ischem,elig_signs___1,elig_signs___2,elig_signs___3,elig_signs___4,elig_card_cath,elig_card_cath_details,elig_cath_disease_severity,elig_cath_vessel,elig_ejection_fraction,elig_cath_ffr,elig_ccta,elig_card_cath_details_2,elig_cath_disease_severity_2,elig_ejection_fraction_2,elig_cta_score,elig_nocom_med,elig_ischemia_dilated,elig_doc_acs,elig_lvef,elig_nyha_class,elig_hos_hfref,elig_stroke,elig_carnial_hemo,elig_renal,elig_valvular,elig_life_expect,elig_enroll_clinic,elig_intol_ace,elig_intol_arb,elig_intol_statin,elig_intol_pcsk,elig_preg,elig_liver_dis,elig_hist_rhab,elig_high_dose,elig_study_yes,elig_date,elig_study_no,eligibility_complete
|
||||
806-1,baseline_arm_1,,,uf_test,,,,,,,,,,,,[document],,,[document],,,2,2018-05-08,Philip,B,Chase,1964-04-09,"5959 NW 13th Ave",Gainesville,FL,32605,"(352) 555-0760",bobsyouruncle@example.org,2,5,,2,111-22-3333,2,1,1,1,0,0,0,1,1,,,60,1,1,1,,60,24,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,,0,0,0,0,1,2018-05-08,,2
|
||||
806-1,followup_month_3_arm_1,,,uf_test,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
||||
806-1,baseline_arm_1,informed_consent,1,uf_test,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
||||
806-1,baseline_arm_1,informed_consent_and_addendum,1,uf_test,,"2018-05-08 21:15:12",Philip,Chase,2018-05-08,[document],"Philip B Chase",UF,[document],2018-05-08,2,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
||||
806-1,baseline_arm_1,informed_consent_and_addendum,2,uf_test,,,Bobs,Youruncle,2018-06-21,[document],"Yo Mama","Anywhere she wants",[document],2018-06-21,2,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
||||
806-1,baseline_arm_1,informed_consent_and_addendum,3,uf_test,,,Bobs,Youruncle,2018-06-21,[document],zsdf,DF,[document],2018-06-21,2,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
||||
806-2,baseline_arm_1,,,uf_test,,,,,,,,,,,,[document],,,[document],,,2,2018-05-08,afadgs,afd,afdsgfd,1977-06-26,24325543,2352453,fwef,32601,"(352) 294-5299",,2,89,,,123-45-6789,2,1,1,0,1,0,0,0,,,,,,0,,,,,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,,0,0,0,0,1,2018-05-08,,2
|
||||
806-2,followup_month_3_arm_1,,,uf_test,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
||||
806-2,baseline_arm_1,informed_consent,1,uf_test,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
||||
806-2,baseline_arm_1,informed_consent_and_addendum,1,uf_test,,"2018-05-08 21:02:39",test,test,2018-05-08,[document],taryn,stoffs,[document],2018-05-08,2,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
||||
|
File diff suppressed because it is too large
Load diff
|
|
@ -1,49 +0,0 @@
|
|||
# Setup -------------------------------------------------------------------
|
||||
|
||||
devtools::load_all()
|
||||
|
||||
library(digest)
|
||||
library(magrittr)
|
||||
library(jsonlite)
|
||||
|
||||
|
||||
ref_data_location <- function(x) file.path("tests","testthat","data", x)
|
||||
|
||||
# RCurl -------------------------------------------------------------------
|
||||
|
||||
REDCap_split(
|
||||
ref_data_location("ExampleProject_records.json") %>% fromJSON,
|
||||
ref_data_location("ExampleProject_metadata.json") %>% fromJSON
|
||||
) %>% digest
|
||||
|
||||
|
||||
# Basic CSV ---------------------------------------------------------------
|
||||
|
||||
REDCap_split(
|
||||
ref_data_location("ExampleProject_DATA_2018-06-07_1129.csv") %>% read.csv,
|
||||
ref_data_location("ExampleProject_DataDictionary_2018-06-07.csv") %>% read.csv
|
||||
) %>% digest
|
||||
|
||||
# REDCap R Export ---------------------------------------------------------
|
||||
|
||||
source("tests/testthat/helper-ExampleProject_R_2018-06-07_1129.r")
|
||||
|
||||
REDCap_split(
|
||||
ref_data_location("ExampleProject_DATA_2018-06-07_1129.csv") %>%
|
||||
read.csv %>%
|
||||
REDCap_process_csv,
|
||||
ref_data_location("ExampleProject_DataDictionary_2018-06-07.csv") %>% read.csv
|
||||
) %>% digest
|
||||
|
||||
# Longitudinal data from @pbchase; Issue #7 -------------------------------
|
||||
|
||||
file_paths <- sapply(
|
||||
c(
|
||||
records = "WARRIORtestForSoftwa_DATA_2018-06-21_1431.csv",
|
||||
metadata = "WARRIORtestForSoftwareUpgrades_DataDictionary_2018-06-21.csv"
|
||||
), ref_data_location
|
||||
)
|
||||
|
||||
redcap <- lapply(file_paths, read.csv, stringsAsFactors = FALSE)
|
||||
redcap[["metadata"]] <- with(redcap, metadata[metadata[,1] > "",])
|
||||
with(redcap, REDCap_split(records, metadata)) %>% digest
|
||||
|
|
@ -1,78 +0,0 @@
|
|||
REDCap_process_csv <- function(data) {
|
||||
#Load Hmisc library
|
||||
if (!requireNamespace("Hmisc", quietly = TRUE)) {
|
||||
stop("This test requires the 'Hmisc' package")
|
||||
}
|
||||
|
||||
Hmisc::label(data$row)="Name"
|
||||
Hmisc::label(data$redcap_repeat_instrument)="Repeat Instrument"
|
||||
Hmisc::label(data$redcap_repeat_instance)="Repeat Instance"
|
||||
Hmisc::label(data$mpg)="Miles/(US) gallon"
|
||||
Hmisc::label(data$cyl)="Number of cylinders"
|
||||
Hmisc::label(data$disp)="Displacement"
|
||||
Hmisc::label(data$hp)="Gross horsepower"
|
||||
Hmisc::label(data$drat)="Rear axle ratio"
|
||||
Hmisc::label(data$wt)="Weight"
|
||||
Hmisc::label(data$qsec)="1/4 mile time"
|
||||
Hmisc::label(data$vs)="V engine?"
|
||||
Hmisc::label(data$am)="Transmission"
|
||||
Hmisc::label(data$gear)="Number of forward gears"
|
||||
Hmisc::label(data$carb)="Number of carburetors"
|
||||
Hmisc::label(data$color_available___red)="Colors Available (choice=Red)"
|
||||
Hmisc::label(data$color_available___green)="Colors Available (choice=Green)"
|
||||
Hmisc::label(data$color_available___blue)="Colors Available (choice=Blue)"
|
||||
Hmisc::label(data$color_available___black)="Colors Available (choice=Black)"
|
||||
Hmisc::label(data$motor_trend_cars_complete)="Complete?"
|
||||
Hmisc::label(data$letter_group___a)="Which group? (choice=A)"
|
||||
Hmisc::label(data$letter_group___b)="Which group? (choice=B)"
|
||||
Hmisc::label(data$letter_group___c)="Which group? (choice=C)"
|
||||
Hmisc::label(data$choice)="Choose one"
|
||||
Hmisc::label(data$grouping_complete)="Complete?"
|
||||
Hmisc::label(data$price)="Sale price"
|
||||
Hmisc::label(data$color)="Color"
|
||||
Hmisc::label(data$customer)="Customer Name"
|
||||
Hmisc::label(data$sale_complete)="Complete?"
|
||||
#Setting Units
|
||||
|
||||
|
||||
#Setting Factors(will create new variable for factors)
|
||||
data$redcap_repeat_instrument.factor = factor(data$redcap_repeat_instrument,levels=c("sale"))
|
||||
data$cyl.factor = factor(data$cyl,levels=c("3","4","5","6","7","8"))
|
||||
data$vs.factor = factor(data$vs,levels=c("1","0"))
|
||||
data$am.factor = factor(data$am,levels=c("0","1"))
|
||||
data$gear.factor = factor(data$gear,levels=c("3","4","5"))
|
||||
data$carb.factor = factor(data$carb,levels=c("1","2","3","4","5","6","7","8"))
|
||||
data$color_available___red.factor = factor(data$color_available___red,levels=c("0","1"))
|
||||
data$color_available___green.factor = factor(data$color_available___green,levels=c("0","1"))
|
||||
data$color_available___blue.factor = factor(data$color_available___blue,levels=c("0","1"))
|
||||
data$color_available___black.factor = factor(data$color_available___black,levels=c("0","1"))
|
||||
data$motor_trend_cars_complete.factor = factor(data$motor_trend_cars_complete,levels=c("0","1","2"))
|
||||
data$letter_group___a.factor = factor(data$letter_group___a,levels=c("0","1"))
|
||||
data$letter_group___b.factor = factor(data$letter_group___b,levels=c("0","1"))
|
||||
data$letter_group___c.factor = factor(data$letter_group___c,levels=c("0","1"))
|
||||
data$choice.factor = factor(data$choice,levels=c("choice1","choice2"))
|
||||
data$grouping_complete.factor = factor(data$grouping_complete,levels=c("0","1","2"))
|
||||
data$color.factor = factor(data$color,levels=c("1","2","3","4"))
|
||||
data$sale_complete.factor = factor(data$sale_complete,levels=c("0","1","2"))
|
||||
|
||||
levels(data$redcap_repeat_instrument.factor)=c("Sale")
|
||||
levels(data$cyl.factor)=c("3","4","5","6","7","8")
|
||||
levels(data$vs.factor)=c("Yes","No")
|
||||
levels(data$am.factor)=c("Automatic","Manual")
|
||||
levels(data$gear.factor)=c("3","4","5")
|
||||
levels(data$carb.factor)=c("1","2","3","4","5","6","7","8")
|
||||
levels(data$color_available___red.factor)=c("Unchecked","Checked")
|
||||
levels(data$color_available___green.factor)=c("Unchecked","Checked")
|
||||
levels(data$color_available___blue.factor)=c("Unchecked","Checked")
|
||||
levels(data$color_available___black.factor)=c("Unchecked","Checked")
|
||||
levels(data$motor_trend_cars_complete.factor)=c("Incomplete","Unverified","Complete")
|
||||
levels(data$letter_group___a.factor)=c("Unchecked","Checked")
|
||||
levels(data$letter_group___b.factor)=c("Unchecked","Checked")
|
||||
levels(data$letter_group___c.factor)=c("Unchecked","Checked")
|
||||
levels(data$choice.factor)=c("Choice 1","Choice 2")
|
||||
levels(data$grouping_complete.factor)=c("Incomplete","Unverified","Complete")
|
||||
levels(data$color.factor)=c("red","green","blue","black")
|
||||
levels(data$sale_complete.factor)=c("Incomplete","Unverified","Complete")
|
||||
|
||||
data
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
# get_data_location <- function(x) {
|
||||
# system.file(
|
||||
# "testdata",
|
||||
# x,
|
||||
# package = "REDCapRITS"
|
||||
# )
|
||||
# }
|
||||
|
||||
get_data_location <- function(x) file.path("data", x)
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
context("Reading in JSON")
|
||||
|
||||
# Check the RCurl export ---------------------------------------------------
|
||||
test_that("JSON character vector from RCurl matches reference", {
|
||||
|
||||
metadata <- jsonlite::fromJSON(
|
||||
get_data_location(
|
||||
"ExampleProject_metadata.json"
|
||||
)
|
||||
)
|
||||
|
||||
records <- jsonlite::fromJSON(
|
||||
get_data_location(
|
||||
"ExampleProject_records.json"
|
||||
)
|
||||
)
|
||||
|
||||
redcap_output_json1 <- REDCap_split(records, metadata)
|
||||
|
||||
expect_known_hash(redcap_output_json1, "2c8b6531597182af1248f92124161e0c")
|
||||
|
||||
})
|
||||
|
||||
# Check the httr export ---------------------------------------------------
|
||||
|
||||
# Something will go here.
|
||||
|
|
@ -1,68 +0,0 @@
|
|||
context("CSV Exports")
|
||||
|
||||
# Set up the path and data -------------------------------------------------
|
||||
metadata <- read.csv(
|
||||
get_data_location("ExampleProject_DataDictionary_2018-06-07.csv"),
|
||||
stringsAsFactors = TRUE
|
||||
)
|
||||
|
||||
records <- read.csv(
|
||||
get_data_location("ExampleProject_DATA_2018-06-07_1129.csv"),
|
||||
stringsAsFactors = TRUE
|
||||
)
|
||||
|
||||
redcap_output_csv1 <- REDCap_split(records, metadata)
|
||||
|
||||
# Test that basic CSV export matches reference ------------------------------
|
||||
test_that("CSV export matches reference", {
|
||||
expect_known_hash(redcap_output_csv1, "f74558d1939c17d9ff0e08a19b956e26")
|
||||
})
|
||||
|
||||
# Test that R code enhanced CSV export matches reference --------------------
|
||||
if (requireNamespace("Hmisc", quietly = TRUE)) {
|
||||
test_that("R code enhanced export matches reference", {
|
||||
redcap_output_csv2 <- REDCap_split(REDCap_process_csv(records), metadata)
|
||||
|
||||
expect_known_hash(redcap_output_csv2, "34f82cab35bf8aae47d08cd96f743e6b")
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
if (requireNamespace("readr", quietly = TRUE)) {
|
||||
|
||||
context("Compatibility with readr")
|
||||
|
||||
metadata <- readr::read_csv(
|
||||
get_data_location(
|
||||
"ExampleProject_DataDictionary_2018-06-07.csv"
|
||||
)
|
||||
)
|
||||
|
||||
records <- readr::read_csv(
|
||||
get_data_location(
|
||||
"ExampleProject_DATA_2018-06-07_1129.csv"
|
||||
)
|
||||
)
|
||||
|
||||
redcap_output_readr <- REDCap_split(records, metadata)
|
||||
|
||||
expect_matching_elements <- function(FUN) {
|
||||
FUN <- match.fun(FUN)
|
||||
expect_identical(
|
||||
lapply(redcap_output_readr, FUN),
|
||||
lapply(redcap_output_csv1, FUN)
|
||||
)
|
||||
}
|
||||
|
||||
test_that("Result of data read in with `readr` will match result with `read.csv`", {
|
||||
|
||||
# The list itself
|
||||
expect_identical(length(redcap_output_readr), length(redcap_output_csv1))
|
||||
expect_identical(names(redcap_output_readr), names(redcap_output_csv1))
|
||||
|
||||
# Each element of the list
|
||||
expect_matching_elements(names)
|
||||
expect_matching_elements(dim)
|
||||
})
|
||||
|
||||
}
|
||||
|
|
@ -1,63 +0,0 @@
|
|||
context("Using the `forms = 'all'` argument")
|
||||
|
||||
# Global variables --------------------------------------------------------
|
||||
|
||||
# Cars
|
||||
metadata <- jsonlite::fromJSON(
|
||||
get_data_location(
|
||||
"ExampleProject_metadata.json"
|
||||
)
|
||||
)
|
||||
|
||||
records <- jsonlite::fromJSON(
|
||||
get_data_location(
|
||||
"ExampleProject_records.json"
|
||||
)
|
||||
)
|
||||
|
||||
redcap_output_json <- REDCap_split(records, metadata, forms = "all")
|
||||
|
||||
# Longitudinal
|
||||
file_paths <- sapply(
|
||||
c(
|
||||
records = "WARRIORtestForSoftwa_DATA_2018-06-21_1431.csv",
|
||||
metadata = "WARRIORtestForSoftwareUpgrades_DataDictionary_2018-06-21.csv"
|
||||
), get_data_location
|
||||
)
|
||||
|
||||
redcap <- lapply(file_paths, read.csv, stringsAsFactors = FALSE)
|
||||
redcap[["metadata"]] <- with(redcap, metadata[metadata[,1] > "",])
|
||||
redcap_output_long <- with(redcap, REDCap_split(records, metadata, forms = "all"))
|
||||
redcap_long_names <- names(redcap[[1]])
|
||||
|
||||
# Tests -------------------------------------------------------------------
|
||||
|
||||
test_that("Each form is an element in the list", {
|
||||
|
||||
expect_length(redcap_output_json, 3L)
|
||||
expect_identical(names(redcap_output_json), c("motor_trend_cars", "grouping", "sale"))
|
||||
|
||||
})
|
||||
|
||||
test_that("All variables land somewhere", {
|
||||
|
||||
expect_true(setequal(names(records), Reduce("union", sapply(redcap_output_json, names))))
|
||||
|
||||
})
|
||||
|
||||
|
||||
test_that("Primary table name is ignored", {
|
||||
expect_identical(
|
||||
REDCap_split(records, metadata, "HELLO", "all"),
|
||||
redcap_output_json
|
||||
)
|
||||
})
|
||||
|
||||
test_that("Supports longitudinal data", {
|
||||
|
||||
# setdiff(redcap_long_names, Reduce("union", sapply(redcap_output_long, names)))
|
||||
## [1] "informed_consent_and_addendum_timestamp"
|
||||
|
||||
expect_true(setequal(redcap_long_names, Reduce("union", sapply(redcap_output_long, names))))
|
||||
|
||||
})
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
context("Longitudinal data")
|
||||
|
||||
test_that("CSV export matches reference", {
|
||||
file_paths <- sapply(
|
||||
c(
|
||||
records = "WARRIORtestForSoftwa_DATA_2018-06-21_1431.csv",
|
||||
metadata = "WARRIORtestForSoftwareUpgrades_DataDictionary_2018-06-21.csv"
|
||||
), get_data_location
|
||||
)
|
||||
|
||||
redcap <- lapply(file_paths, read.csv, stringsAsFactors = FALSE)
|
||||
redcap[["metadata"]] <- with(redcap, metadata[metadata[,1] > "",])
|
||||
redcap_output <- with(redcap, REDCap_split(records, metadata))
|
||||
|
||||
|
||||
expect_known_hash(redcap_output, "0934bcb292")
|
||||
})
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
context("Primary table name processing")
|
||||
|
||||
|
||||
# Global variables -------------------------------------------------------
|
||||
metadata <- jsonlite::fromJSON(
|
||||
get_data_location(
|
||||
"ExampleProject_metadata.json"
|
||||
)
|
||||
)
|
||||
|
||||
records <- jsonlite::fromJSON(
|
||||
get_data_location(
|
||||
"ExampleProject_records.json"
|
||||
)
|
||||
)
|
||||
|
||||
ref_hash <- "2c8b6531597182af1248f92124161e0c"
|
||||
|
||||
# Tests -------------------------------------------------------------------
|
||||
test_that("Will not use a repeating instrument name for primary table", {
|
||||
|
||||
redcap_output_json1 <- expect_warning(
|
||||
REDCap_split(records, metadata, "sale"),
|
||||
"primary table"
|
||||
)
|
||||
|
||||
expect_known_hash(redcap_output_json1, ref_hash)
|
||||
|
||||
})
|
||||
|
||||
test_that("Names are set correctly and output is identical", {
|
||||
redcap_output_json2 <- REDCap_split(records, metadata, "main")
|
||||
|
||||
|
||||
expect_identical(names(redcap_output_json2), c("main", "sale"))
|
||||
expect_known_hash(setNames(redcap_output_json2, c("", "sale")), ref_hash)
|
||||
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue