I have a data frame that I create as such:
> yyz <- data.frame(a = c("1","2","n/a"), b = c(1,2,"n/a")) > apply(yyz, 2, class) ab "character" "character"
I am trying to convert the last column to a numeric one while keeping the first column as a character. I tried this:
> yyz$b <- as.numeric(as.character(yyz$b)) > yyz ab 1 1 2 2 n/a NA
But when I run the apply class, it shows me that they are both character classes.
> apply(yyz, 2, class) ab "character" "character"
Am I setting the data frame incorrectly? Or is it the way R interprets a data frame?
r
user5124826
source share