Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 204715

coercing columns of a data frame to numeric

$
0
0

I can't get the following formula to coerce selected columns of a data frame to numeric

x<-read.csv("more.csv",colClasses="character")

test<-list(more[,10],more[,11],more[,12])
test2<-lapply(test,as.numeric)

But

is.numeric(more[,10])
[1] FALSE

When I use the following formula it works:

more[,10]<-as.numeric(more[,10])

is.numeric(more[,10])
[1] TRUE

I can't make out the error in the first formula used.


Viewing all articles
Browse latest Browse all 204715

Trending Articles