retype: Change classes of columns in a data.frame

View source: R/skUtils.R

retypeR Documentation

Change classes of columns in a data.frame

Description

retype() changes the class of specific columns; retype_all() changes the class of all columns of a given class.

Usage

retype(df, ...)

retype_all(df, from, to)

Arguments

df

A data.frame.

...

Unquoted column names, paired with the desired class, e.g.

age = numeric(), language = character()

from

An empty vector of the class to convert from, or a string. Columns sharing the class of argument from will be converted to the class of argument to.

to

An empty vector of the class to convert to, or a string. Columns sharing the class of argument from will be converted to the class of argument to.

Author(s)

Sercan Kahveci

Examples

sapply(ToothGrowth,class)
NewToothGrowth <- retype(ToothGrowth, supp = character(), dose = factor())
sapply(NewToothGrowth,class)


sapply(mtcars,class)
newmtcars <- retype_all(mtcars,from="numeric",to="character")
sapply(newmtcars,class)


Spiritspeak/skMisc documentation built on April 12, 2025, 5:40 a.m.