merge master in s3methods

This commit is contained in:
pegeler 2018-06-25 23:54:58 -04:00
commit 6f14bbbeca
9 changed files with 1929 additions and 5 deletions

View File

@ -13,7 +13,8 @@ Suggests:
RCurl,
httr,
jsonlite,
testthat
testthat,
Hmisc
License: GPL-3
Encoding: UTF-8
LazyData: true

View File

@ -1,4 +1,4 @@
# library(testthat)
# library(REDCapRITS)
#
# test_check("REDCapRITS")
library(testthat)
library(REDCapRITS)
test_check("REDCapRITS")

View File

@ -0,0 +1,46 @@
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 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
2 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
3 AMC Javelin sale 1 12000.50 1 Bob 0
4 AMC Javelin sale 2 13750.77 3 Sue 2
5 AMC Javelin sale 3 15004.57 2 Kim 0
6 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
7 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
8 Camaro Z28 sale 1 7800.00 2 Janice 2
9 Camaro Z28 sale 2 8000.00 3 Tim 0
10 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
11 Chrysler Imperial sale 1 7500.00 1 Jim 2
12 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
13 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
14 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
15 Duster 360 sale 1 8756.40 4 Sarah 1
16 Duster 360 sale 2 6800.88 2 Pablo 0
17 Duster 360 sale 3 8888.88 1 Erica 0
18 Duster 360 sale 4 970.00 4 Juan 0
19 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
20 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
21 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
22 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
23 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
24 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
25 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
26 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
27 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
28 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
29 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
30 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
31 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
32 Merc 230 sale 1 7800.98 2 Ted 0
33 Merc 230 sale 2 7954.00 1 Quentin 0
34 Merc 230 sale 3 6800.55 3 Sharon 2
35 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
36 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
37 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
38 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
39 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
40 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
41 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
42 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
43 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
44 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
45 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
46 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

View File

@ -0,0 +1,19 @@
"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 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
2 row motor_trend_cars text Name
3 mpg motor_trend_cars text Miles/(US) gallon number
4 cyl motor_trend_cars radio Number of cylinders 3, 3 | 4, 4 | 5, 5 | 6, 6 | 7, 7 | 8, 8
5 disp motor_trend_cars text Displacement (cu.in.) number
6 hp motor_trend_cars text Gross horsepower number
7 drat motor_trend_cars text Rear axle ratio number
8 wt motor_trend_cars text Weight (1000 lbs) number
9 qsec motor_trend_cars text 1/4 mile time number
10 vs motor_trend_cars yesno V engine?
11 am motor_trend_cars dropdown Transmission 0, Automatic | 1, Manual (0 = automatic, 1 = manual)
12 gear motor_trend_cars radio Number of forward gears 3, 3 | 4, 4 | 5, 5
13 carb motor_trend_cars radio Number of carburetors 1, 1 | 2, 2 | 3, 3 | 4, 4 | 5, 5 | 6, 6 | 7, 7 | 8, 8
14 color_available motor_trend_cars checkbox Colors Available red, Red | green, Green | blue, Blue | black, Black
15 letter_group grouping checkbox Which group? a, A | b, B | c, C
16 choice grouping radio Choose one choice1, Choice 1 | choice2, Choice 2
17 price sale text Sale price number_2dp
18 color sale dropdown Color 1, red | 2, green | 3, blue | 4, black
19 customer sale text Customer Name RH

View File

@ -0,0 +1,77 @@
REDCap_process_csv <- function(data) {
#Load Hmisc library
if (!require(Hmisc))
stop("This test requires the 'Hmisc' package")
label(data$row)="Name"
label(data$redcap_repeat_instrument)="Repeat Instrument"
label(data$redcap_repeat_instance)="Repeat Instance"
label(data$mpg)="Miles/(US) gallon"
label(data$cyl)="Number of cylinders"
label(data$disp)="Displacement"
label(data$hp)="Gross horsepower"
label(data$drat)="Rear axle ratio"
label(data$wt)="Weight"
label(data$qsec)="1/4 mile time"
label(data$vs)="V engine?"
label(data$am)="Transmission"
label(data$gear)="Number of forward gears"
label(data$carb)="Number of carburetors"
label(data$color_available___red)="Colors Available (choice=Red)"
label(data$color_available___green)="Colors Available (choice=Green)"
label(data$color_available___blue)="Colors Available (choice=Blue)"
label(data$color_available___black)="Colors Available (choice=Black)"
label(data$motor_trend_cars_complete)="Complete?"
label(data$letter_group___a)="Which group? (choice=A)"
label(data$letter_group___b)="Which group? (choice=B)"
label(data$letter_group___c)="Which group? (choice=C)"
label(data$choice)="Choose one"
label(data$grouping_complete)="Complete?"
label(data$price)="Sale price"
label(data$color)="Color"
label(data$customer)="Customer Name"
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
}

View File

@ -0,0 +1,362 @@
[
{
"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

View File

@ -0,0 +1,32 @@
context("Reading in JSON")
# Set up the path ----------------------------------------------------------
data_dir <- system.file("tests", "testthat", "data", package = "REDCapRITS")
# Check the RCurl export ---------------------------------------------------
test_that("JSON character vector from RCurl matches reference", {
metadata <- jsonlite::fromJSON(
file.path(
data_dir,
"ExampleProject_metadata.json"
)
)
records <- jsonlite::fromJSON(
file.path(
data_dir,
"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.

View File

@ -0,0 +1,35 @@
context("CSV Exports")
# Set up the path and data -------------------------------------------------
data_dir <- system.file("tests", "testthat", "data", package = "REDCapRITS")
metadata <- read.csv(
file.path(
data_dir,
"ExampleProject_DataDictionary_2018-06-07.csv"
)
)
records <- read.csv(
file.path(
data_dir,
"ExampleProject_DATA_2018-06-07_1129.csv"
)
)
# Test that basic CSV export matches reference ------------------------------
test_that("CSV export matches reference", {
redcap_output_csv1 <- REDCap_split(records, metadata)
expect_known_hash(redcap_output_csv1, "f74558d1939c17d9ff0e08a19b956e26")
})
# Test that R code enhanced CSV export matches reference --------------------
test_that("R code enhanced export matches reference", {
source(file.path(data_dir, "ExampleProject_R_2018-06-07_1129.r"))
redcap_output_csv2 <- REDCap_split(REDCap_process_csv(records), metadata)
expect_known_hash(redcap_output_csv2, "34f82cab35bf8aae47d08cd96f743e6b")
})