change_formats_dataframe: Change formats of columns in dataframe

View source: R/change_formats_dataframe.R

change_formats_dataframeR Documentation

Change formats of columns in dataframe

Description

Apply column formats as defined in formats file to dataframe.

Usage

change_formats_dataframe(
  df,
  formats_df = formats,
  char_vars = FALSE,
  factor_vars = FALSE,
  post_dm = FALSE,
  var_selection = c("_all")
)

Arguments

df

dataframe

formats_df

dataframe defining the formats. Must be in standard format containing columns Variable_name, Import_format and Sorting_order.

char_vars

Logical if TRUE, all variables that are defined as "String" in column Variable_type of the formats file will be changed to as.character.

factor_vars

Logical if TRUE, all variables that are defined as "Labelled num" in column Variable_type and "Ordinal" or "Nominal" in column Measurement_level of the formats file will be changed to sjlabelled::as_label, keep.labels = TRUE.

post_dm

Logical; if FALSE, all variables are added as part of data management steps defined as "not imported" in column Import_format of the formats file will be omitted.

var_selection

Character vector of selected variables will be changed. Default var_selection = c("all") means that all variables are selected.

Value

dataframe


marianschmidt/msAutolabelR documentation built on April 17, 2022, 7:42 a.m.