mirror of
https://github.com/agdamsbo/REDCapCAST.git
synced 2026-06-19 13:17:30 +02:00
working to submit to cran
This commit is contained in:
parent
992091f94c
commit
be3969d007
11 changed files with 200 additions and 265 deletions
|
|
@ -1,4 +1,3 @@
|
|||
context("CSV Exports")
|
||||
|
||||
# Set up the path and data -------------------------------------------------
|
||||
metadata <- read.csv(
|
||||
|
|
@ -6,10 +5,8 @@ metadata <- read.csv(
|
|||
stringsAsFactors = TRUE
|
||||
)
|
||||
|
||||
records <- read.csv(
|
||||
get_data_location("ExampleProject_DATA_2018-06-07_1129.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)
|
||||
|
||||
|
|
@ -21,48 +18,38 @@ test_that("CSV export matches reference", {
|
|||
# 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)
|
||||
redcap_output_csv2 <-
|
||||
REDCap_split(REDCap_process_csv(records), metadata)
|
||||
|
||||
expect_known_hash(redcap_output_csv2, "34f82cab35bf8aae47d08cd96f743e6b")
|
||||
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"
|
||||
)
|
||||
)
|
||||
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"
|
||||
)
|
||||
)
|
||||
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)
|
||||
)
|
||||
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`", {
|
||||
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))
|
||||
|
||||
# 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)
|
||||
})
|
||||
# Each element of the list
|
||||
expect_matching_elements(names)
|
||||
expect_matching_elements(dim)
|
||||
})
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue