data(rotif.env)
str(rotif.env)
# convert the first 4 columns to character:
converted.rotif.env <- multConvert(data = rotif.env,
conversion = as.character, cols = 1:4)
str(converted.rotif.env)
# divide some columns by 100:
div100 <- function(x) {
x / 100
}
rotif.env.div100 <- multConvert(data = rotif.env,
conversion = div100, cols = c(6:10, 12:17))
head(rotif.env.div100)
# scale (standardize) continuous variables:
names(rotif.env)
conts <- names(which(sapply(rotif.env[ , 1:17], is.numeric)))
rotif.env.scaled <- multConvert(data = rotif.env,
conversion = scale, cols = conts)
head(rotif.env.scaled)
Run the code above in your browser using DataLab