Learn R Programming

ctrdata (version 1.6.0)

dfMergeTwoVariablesRelevel: Merge two variables into one, optionally map values to new levels

Description

Merge two variables into one, optionally map values to new levels

Usage

dfMergeTwoVariablesRelevel(df = NULL, colnames = "", levelslist = NULL, ...)

Arguments

df

A data.frame in which there are two variables (columns) to be merged into one.

colnames

A vector of length two with names of the two columns that hold the variables to be merged. See colnames for how to obtain the names of columns of a data frame.

levelslist

A list with one slice each for a new value to be used for a vector of old values (optional).

...

for deprecated varnames parameter (will be removed)

Value

A vector of strings

Examples

Run this code
# NOT RUN {
# }
# NOT RUN {
statusvalues <- list(
  "ongoing" = c("Recruiting", "Active", "Ongoing",
                "Active, not recruiting", "Enrolling by invitation"),
  "completed" = c("Completed", "Prematurely Ended", "Terminated"),
  "other" = c("Withdrawn", "Suspended",
              "No longer available", "Not yet recruiting"))

dfMergeTwoVariablesRelevel(
  df = result,
  colnames = c("Recruitment", "x5_trial_status"),
  levelslist = statusvalues)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab