Learn R Programming

loon (version 1.4.1)

char2num.data.frame: A Character Data Frame to a Numerical Data Frame

Description

Turn a data frame of characters to a data frame of numerical values. If the character cannot be converted to numerical in direct, it will be turned to factor first, then to numerical data

Usage

char2num.data.frame(chardataframe)

Arguments

chardataframe

A char data frame

Examples

Run this code
data <- data.frame(x = c("1", "2", "3"),
                   y = c("foo", "bar", "foo"),
                   z = 4:6)
# ERROR
# data + 1
numData <- char2num.data.frame(data)
numData + 1

if(interactive()) {
  s <- l_serialaxes(iris)
  data <- s["data"]
  # it is a character data frame
  data[1,1]
  numData <- char2num.data.frame(data)
  numData[1,1]
}

Run the code above in your browser using DataLab