For rename dataset
rename_dataset( dataset, path_crfs, no_readable_name, readable_name, num_sheet = 1, extension = "*.xlsx", is_post = T )
dataset | A dataset, a type is a data frame. |
---|---|
path_crfs | A character scalar. Path to the specification files the in excel table. |
no_readable_name | A character scalar. A column name of no_readable values. |
readable_name | A character scalar. A column name of readable values. |
num_sheet | An integer scalar, default is the first sheet. A position of a sheet in the excel document. |
extension | A character scalar. A extension of files, default is *.xlsx. |
is_post | A logical scalar, default is TRUE. True is postfix, otherwise, prefix. |
The list with two values: data - renamed dataset, spec - common specification. The common specification is data frame of two values: no_readable_var, readable_var.
id <- c("01", "02", "03") age <- c("19", "20", "22") sex <- c("f", "m", "f") bio_date_post <- c("1991-03-23", "1991-03-16", "1991-03-16") gluc_post <- c("5.5", "4.1", "9.7") gluc_res_post <- c("norm", "no", "norm") df <- data.frame( id, age, sex, bio_date_post, gluc_post, gluc_res_post, stringsAsFactors = FALSE ) crfs <- system.file("forms", package = "dmtools") result <- rename_dataset(df, crfs, "old_name", "new_name") result[["data"]]#> id age sex blood biochemistry date_post glucose test_post #> 1 01 19 f 1991-03-23 5.5 #> 2 02 20 m 1991-03-16 4.1 #> 3 03 22 f 1991-03-16 9.7 #> result is normal_post #> 1 norm #> 2 no #> 3 norm