-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
415 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
utils::globalVariables(c("redcapcast_meta")) | ||
#' Data set to data dictionary function | ||
#' | ||
#' Migrated from stRoke ds2dd(). Fits better with the functionality of | ||
#' 'REDCapCAST' | ||
#' @param ds data set | ||
#' @param record.id name or column number of id variable, moved to first row of | ||
#' data dictionary, character of integer. Default is "record_id". | ||
#' @param form.name vector of form names, character string, length 1 or length | ||
#' equal to number of variables. Default is "basis". | ||
#' @param field.type vector of field types, character string, length 1 or length | ||
#' equal to number of variables. Default is "text. | ||
#' @param field.label vector of form names, character string, length 1 or length | ||
#' equal to number of variables. Default is NULL and is then identical to field | ||
#' names. | ||
#' @param include.column.names Flag to give detailed output including new | ||
#' column names for original data set for upload. | ||
#' @param metadata Metadata column names. Default is the included | ||
#' REDCapCAST::redcapcast_data. | ||
#' | ||
#' @return data.frame or list of data.frame and vector | ||
#' @export | ||
#' | ||
#' @examples | ||
#' redcapcast_data$record_id <- seq_len(nrow(redcapcast_data)) | ||
#' ds2dd(redcapcast_data, include.column.names=TRUE) | ||
|
||
ds2dd <- | ||
function(ds, | ||
record.id = "record_id", | ||
form.name = "basis", | ||
field.type = "text", | ||
field.label = NULL, | ||
include.column.names = FALSE, | ||
metadata = names(redcapcast_meta)) { | ||
dd <- data.frame(matrix(ncol = length(metadata), nrow = ncol(ds))) | ||
colnames(dd) <- metadata | ||
|
||
if (is.character(record.id) & !record.id %in% colnames(ds)) { | ||
stop("Provided record.id is not a variable name in provided data set.") | ||
} | ||
|
||
# renaming to lower case and substitute spaces with underscore | ||
field.name <- gsub(" ", "_", tolower(colnames(ds))) | ||
|
||
# handles both character and integer | ||
colsel <- | ||
colnames(ds) == colnames(ds[record.id]) | ||
|
||
if (summary(colsel)[3] != 1) { | ||
stop("Provided record.id has to be or refer to a uniquely named column.") | ||
} | ||
|
||
dd[, "field_name"] <- | ||
c(field.name[colsel], field.name[!colsel]) | ||
|
||
if (length(form.name) > 1 & length(form.name) != ncol(ds)) { | ||
stop( | ||
"Provided form.name should be of length 1 (value is reused) or equal | ||
length as number of variables in data set." | ||
) | ||
} | ||
dd[, "form_name"] <- form.name | ||
|
||
if (length(field.type) > 1 & length(field.type) != ncol(ds)) { | ||
stop( | ||
"Provided field.type should be of length 1 (value is reused) or equal | ||
length as number of variables in data set." | ||
) | ||
} | ||
|
||
dd[, "field_type"] <- field.type | ||
|
||
if (is.null(field.label)) { | ||
dd[, "field_label"] <- dd[, "field_name"] | ||
} else | ||
dd[, "field_label"] <- field.label | ||
|
||
if (include.column.names){ | ||
list("DataDictionary"=dd,"Column names"=field.name) | ||
} else dd | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,41 @@ | ||
## Test environments | ||
- R-hub windows-x86_64-devel (r-devel) | ||
- R-hub ubuntu-gcc-release (r-release) | ||
- R-hub fedora-clang-devel (r-devel) | ||
|
||
## R CMD check results | ||
❯ On windows-x86_64-devel (r-devel) | ||
checking CRAN incoming feasibility ... [17s] NOTE | ||
Maintainer: 'Andreas Gammelgaard Damsbo <agdamsbo@clin.au.dk>' | ||
|
||
New submission | ||
|
||
Possibly misspelled words in DESCRIPTION: | ||
Egeler (8:45) | ||
REDCap (2:8, 10:39, 11:30, 14:5) | ||
REDCapRITS (8:26) | ||
interoperability (19:44) | ||
|
||
❯ On windows-x86_64-devel (r-devel) | ||
checking for non-standard things in the check directory ... NOTE | ||
Found the following files/directories: | ||
## rhub::check_for_cran() results | ||
|
||
── REDCapCAST 23.6.2: NOTE | ||
|
||
Build ID: REDCapCAST_23.6.2.tar.gz-a738190c0d8a4e76b9212e4915625f96 | ||
Platform: Windows Server 2022, R-devel, 64 bit | ||
Submitted: 56m 54.3s ago | ||
Build time: 4m 25.1s | ||
|
||
❯ On windows-x86_64-devel (r-devel) | ||
checking for detritus in the temp directory ... NOTE | ||
❯ checking for non-standard things in the check directory ... NOTE | ||
''NULL'' | ||
|
||
❯ checking for detritus in the temp directory ... NOTE | ||
Found the following files/directories: | ||
'lastMiKTeXException' | ||
|
||
❯ On ubuntu-gcc-release (r-release) | ||
checking CRAN incoming feasibility ... [6s/24s] NOTE | ||
Maintainer: ‘Andreas Gammelgaard Damsbo <agdamsbo@clin.au.dk>’ | ||
|
||
New submission | ||
|
||
Possibly misspelled words in DESCRIPTION: | ||
Egeler (8:45) | ||
REDCap (2:8, 10:39, 11:30, 14:5) | ||
REDCapRITS (8:26) | ||
|
||
❯ On ubuntu-gcc-release (r-release), fedora-clang-devel (r-devel) | ||
checking HTML version of manual ... NOTE | ||
0 errors ✔ | 0 warnings ✔ | 2 notes ✖ | ||
|
||
── REDCapCAST 23.6.2: NOTE | ||
|
||
Build ID: REDCapCAST_23.6.2.tar.gz-a9243a74abae4f04b2a0e29a2751c420 | ||
Platform: Ubuntu Linux 20.04.1 LTS, R-release, GCC | ||
Submitted: 56m 54.4s ago | ||
Build time: 32m 6.5s | ||
|
||
❯ checking HTML version of manual ... NOTE | ||
Skipping checking HTML validation: no command 'tidy' found | ||
|
||
0 errors ✔ | 0 warnings ✔ | 1 note ✖ | ||
|
||
── REDCapCAST 23.6.2: NOTE | ||
|
||
Build ID: REDCapCAST_23.6.2.tar.gz-ba8ade3478c6494b8a8daee08a502f2b | ||
Platform: Fedora Linux, R-devel, clang, gfortran | ||
Submitted: 56m 54.4s ago | ||
Build time: 29m 25.6s | ||
|
||
❯ checking HTML version of manual ... NOTE | ||
Skipping checking HTML validation: no command 'tidy' found | ||
|
||
❯ On fedora-clang-devel (r-devel) | ||
checking CRAN incoming feasibility ... [7s/21s] NOTE | ||
Maintainer: ‘Andreas Gammelgaard Damsbo <agdamsbo@clin.au.dk>’ | ||
|
||
New submission | ||
|
||
Possibly misspelled words in DESCRIPTION: | ||
Egeler (8:45) | ||
REDCap (2:8, 10:39, 11:30, 14:5) | ||
REDCapRITS (8:26) | ||
|
||
0 errors ✔ | 0 warnings ✔ | 6 notes ✖ | ||
0 errors ✔ | 0 warnings ✔ | 1 note ✖ |
Oops, something went wrong.