Learn R Programming

clinCompare (version 1.0.0)

convert_data_types: Converts the data types of specified variables in a dataset.

Description

Converts columns in a data frame to specified types based on a named list mapping column names to target types. Supports conversion to numeric, character, factor, integer, logical, and other R data types.

Usage

convert_data_types(df, conversions)

Value

A data frame with converted variable types.

Arguments

df

A data frame containing the variables to be converted.

conversions

A named list where names correspond to variable names in the dataset, and values are the desired data types (e.g., 'numeric', 'factor').