rename_dataset {dmtools}R Documentation

For rename dataset

Description

For rename dataset

Usage

rename_dataset(
  dataset,
  path_crfs,
  no_readable_name,
  readable_name,
  num_sheet = 1,
  extension = "*.xlsx",
  is_post = T
)

Arguments

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.

Value

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.

Examples

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"]]

[Package dmtools version 0.2.6 Index]