View source: R/dfMergeVariablesRelevel.R
dfMergeVariablesRelevel | R Documentation |
Merge variables in a data frame such as returned by dbGetFieldsIntoDf into a new variable, and optionally also map its values to new levels. See ctrdata-trial-concepts for pre-defined cross-register concepts that are already implemented based on merging fields from different registers and calculating a new field.
dfMergeVariablesRelevel(df = NULL, colnames = "", levelslist = NULL)
df |
A data.frame with the variables (columns) to be merged into one vector. |
colnames |
A vector of names of columns in 'df' that hold the variables
to be merged, or a selection of columns as per |
levelslist |
A names list with one slice each for a new value to be used for a vector of old values (optional). |
A vector, with the type of the columns to be merged
dbc <- nodbi::src_sqlite(
dbname = system.file("extdata", "demo.sqlite", package = "ctrdata"),
collection = "my_trials",
flags = RSQLite::SQLITE_RO)
df <- dbGetFieldsIntoDf(
fields = c(
"protocolSection.eligibilityModule.healthyVolunteers",
"f31_healthy_volunteers",
"eligibility.healthy_volunteers"
),
con = dbc
)
table(
dfMergeVariablesRelevel(
df = df,
colnames = 'matches("healthy")'
))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.