ds2dd bug fixed and new param to specify metadata

This commit is contained in:
Andreas Gammelgaard Damsbo 2023-07-03 12:00:36 +02:00
parent 55679c7845
commit fed6711990
4 changed files with 18 additions and 5 deletions

View File

@ -1,6 +1,6 @@
Package: stRoke Package: stRoke
Title: Clinical Stroke Research Title: Clinical Stroke Research
Version: 23.6.2 Version: 23.6.3
Authors@R: Authors@R:
person("Andreas Gammelgaard", "Damsbo", , "agdamsbo@clin.au.dk", role = c("aut", "cre"), person("Andreas Gammelgaard", "Damsbo", , "agdamsbo@clin.au.dk", role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-7559-1154")) comment = c(ORCID = "0000-0002-7559-1154"))

View File

@ -1,3 +1,9 @@
# stRoke 23.6.3
### Bug
* Fixed `ds2dd()` bug after first practical implementation.
# stRoke 23.6.2 # stRoke 23.6.2
### Functions: ### Functions:

View File

@ -13,6 +13,8 @@ utils::globalVariables(c("metadata_names"))
#' names. #' names.
#' @param include.column.names Flag to give detailed output including new #' @param include.column.names Flag to give detailed output including new
#' column names for original data set for upload. #' column names for original data set for upload.
#' @param metadata Metadata dataframe. Default is the included
#' stRoke::metadata_names.
#' #'
#' @return data.frame or list of data.frame and vector #' @return data.frame or list of data.frame and vector
#' @export #' @export
@ -27,9 +29,10 @@ ds2dd <-
form.name = "basis", form.name = "basis",
field.type = "text", field.type = "text",
field.label = NULL, field.label = NULL,
include.column.names = FALSE) { include.column.names = FALSE,
dd <- data.frame(matrix(ncol = length(metadata_names), nrow = ncol(ds))) metadata = stRoke::metadata_names) {
colnames(dd) <- metadata_names dd <- data.frame(matrix(ncol = length(metadata), nrow = ncol(ds)))
colnames(dd) <- metadata
if (is.character(record.id) & !record.id %in% colnames(ds)) { if (is.character(record.id) & !record.id %in% colnames(ds)) {
stop("Provided record.id is not a variable name in provided data set.") stop("Provided record.id is not a variable name in provided data set.")

View File

@ -10,7 +10,8 @@ ds2dd(
form.name = "basis", form.name = "basis",
field.type = "text", field.type = "text",
field.label = NULL, field.label = NULL,
include.column.names = FALSE include.column.names = FALSE,
metadata = stRoke::metadata_names
) )
} }
\arguments{ \arguments{
@ -31,6 +32,9 @@ names.}
\item{include.column.names}{Flag to give detailed output including new \item{include.column.names}{Flag to give detailed output including new
column names for original data set for upload.} column names for original data set for upload.}
\item{metadata}{Metadata dataframe. Default is the included
stRoke::metadata_names.}
} }
\value{ \value{
data.frame or list of data.frame and vector data.frame or list of data.frame and vector