mirror of
https://github.com/agdamsbo/REDCapCAST.git
synced 2026-06-19 13:17:30 +02:00
Major update. New functions and improvements. See NEWS.md.
This commit is contained in:
parent
b57e130395
commit
9f68e27f5a
20 changed files with 443 additions and 97 deletions
19
man/focused_metadata.Rd
Normal file
19
man/focused_metadata.Rd
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
% Generated by roxygen2: do not edit by hand
|
||||
% Please edit documentation in R/utils.r
|
||||
\name{focused_metadata}
|
||||
\alias{focused_metadata}
|
||||
\title{focused_metadata}
|
||||
\usage{
|
||||
focused_metadata(metadata, vars_in_data)
|
||||
}
|
||||
\arguments{
|
||||
\item{metadata}{A dataframe containing metadata}
|
||||
|
||||
\item{vars_in_data}{Vector of variable names in the dataset}
|
||||
}
|
||||
\value{
|
||||
A dataframe containing metadata for the variables in the dataset
|
||||
}
|
||||
\description{
|
||||
Extracts limited metadata for variables in a dataset
|
||||
}
|
||||
19
man/match_fields_to_form.Rd
Normal file
19
man/match_fields_to_form.Rd
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
% Generated by roxygen2: do not edit by hand
|
||||
% Please edit documentation in R/utils.r
|
||||
\name{match_fields_to_form}
|
||||
\alias{match_fields_to_form}
|
||||
\title{Match fields to forms}
|
||||
\usage{
|
||||
match_fields_to_form(metadata, vars_in_data)
|
||||
}
|
||||
\arguments{
|
||||
\item{metadata}{A data frame containing field names and form names}
|
||||
|
||||
\item{vars_in_data}{A character vector of variable names}
|
||||
}
|
||||
\value{
|
||||
A data frame containing field names and form names
|
||||
}
|
||||
\description{
|
||||
Match fields to forms
|
||||
}
|
||||
|
|
@ -12,9 +12,9 @@ read_redcap_tables(
|
|||
events = NULL,
|
||||
forms = NULL,
|
||||
raw_or_label = "label",
|
||||
split_forms = "all",
|
||||
generics = c("record_id", "redcap_event_name", "redcap_repeat_instrument",
|
||||
"redcap_repeat_instance"),
|
||||
...
|
||||
"redcap_repeat_instance")
|
||||
)
|
||||
}
|
||||
\arguments{
|
||||
|
|
@ -32,16 +32,18 @@ read_redcap_tables(
|
|||
|
||||
\item{raw_or_label}{raw or label tags}
|
||||
|
||||
\item{split_forms}{Whether to split "repeating" or "all" forms, default is all.}
|
||||
|
||||
\item{generics}{vector of auto-generated generic variable names to
|
||||
ignore when discarding empty rows}
|
||||
|
||||
\item{...}{ekstra parameters for REDCapR::redcap_read_oneshot}
|
||||
}
|
||||
\value{
|
||||
list of instruments
|
||||
}
|
||||
\description{
|
||||
Wrapper function for using REDCapR::redcap_read and REDCapRITS::REDCap_split
|
||||
Implementation of REDCap_split with a focused data acquisition approach using
|
||||
REDCapR::redcap_read nad only downloading specified fields, forms and/or events
|
||||
using the built-in focused_metadata
|
||||
including some clean-up. Works with longitudinal projects with repeating
|
||||
instruments.
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,18 +4,25 @@
|
|||
\alias{redcap_wider}
|
||||
\title{Redcap Wider}
|
||||
\usage{
|
||||
redcap_wider(list, names.glud = "{.value}_{redcap_event_name}_long")
|
||||
redcap_wider(
|
||||
list,
|
||||
event.glue = "{.value}_{redcap_event_name}",
|
||||
inst.glue = "{.value}_{redcap_repeat_instance}"
|
||||
)
|
||||
}
|
||||
\arguments{
|
||||
\item{list}{A list of data frames.}
|
||||
|
||||
\item{names.glud}{A string to glue the column names together.}
|
||||
\item{event.glue}{A dplyr::glue string for repeated events naming}
|
||||
|
||||
\item{inst.glue}{A dplyr::glue string for repeated instruments naming}
|
||||
}
|
||||
\value{
|
||||
The list of data frames in wide format.
|
||||
}
|
||||
\description{
|
||||
Converts a list of REDCap data frames from long to wide format.
|
||||
Handles longitudinal projects, but not yet repeated instruments.
|
||||
}
|
||||
\examples{
|
||||
list <- list(data.frame(record_id = c(1,2,1,2),
|
||||
|
|
|
|||
23
man/sanitize_split.Rd
Normal file
23
man/sanitize_split.Rd
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
% Generated by roxygen2: do not edit by hand
|
||||
% Please edit documentation in R/utils.r
|
||||
\name{sanitize_split}
|
||||
\alias{sanitize_split}
|
||||
\title{Sanitize list of data frames}
|
||||
\usage{
|
||||
sanitize_split(
|
||||
l,
|
||||
generic.names = c("record_id", "redcap_event_name", "redcap_repeat_instrument",
|
||||
"redcap_repeat_instance")
|
||||
)
|
||||
}
|
||||
\arguments{
|
||||
\item{l}{A list of data frames.}
|
||||
|
||||
\item{generic.names}{A vector of generic names to be excluded.}
|
||||
}
|
||||
\value{
|
||||
A list of data frames with generic names excluded.
|
||||
}
|
||||
\description{
|
||||
Removing empty rows
|
||||
}
|
||||
48
man/split_non_repeating_forms.Rd
Normal file
48
man/split_non_repeating_forms.Rd
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
% Generated by roxygen2: do not edit by hand
|
||||
% Please edit documentation in R/utils.r
|
||||
\name{split_non_repeating_forms}
|
||||
\alias{split_non_repeating_forms}
|
||||
\title{Split a data frame into separate tables for each form}
|
||||
\usage{
|
||||
split_non_repeating_forms(table, universal_fields, fields)
|
||||
}
|
||||
\arguments{
|
||||
\item{table}{A data frame}
|
||||
|
||||
\item{universal_fields}{A character vector of fields that should be included
|
||||
in every table}
|
||||
|
||||
\item{fields}{A two-column matrix containing the names of fields that should
|
||||
be included in each form}
|
||||
}
|
||||
\value{
|
||||
A list of data frames, one for each non-repeating form
|
||||
}
|
||||
\description{
|
||||
Split a data frame into separate tables for each form
|
||||
}
|
||||
\examples{
|
||||
# Create a table
|
||||
table <- data.frame(
|
||||
id = c(1, 2, 3, 4, 5),
|
||||
form_a_name = c("John", "Alice", "Bob", "Eve", "Mallory"),
|
||||
form_a_age = c(25, 30, 25, 15, 20),
|
||||
form_b_name = c("John", "Alice", "Bob", "Eve", "Mallory"),
|
||||
form_b_gender = c("M", "F", "M", "F", "F")
|
||||
)
|
||||
|
||||
# Create the universal fields
|
||||
universal_fields <- c("id")
|
||||
|
||||
# Create the fields
|
||||
fields <- matrix(
|
||||
c("form_a_name", "form_a",
|
||||
"form_a_age", "form_a",
|
||||
"form_b_name", "form_b",
|
||||
"form_b_gender", "form_b"),
|
||||
ncol = 2, byrow = TRUE
|
||||
)
|
||||
|
||||
# Split the table
|
||||
split_non_repeating_forms(table, universal_fields, fields)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue