[R] converting character to numeric

Steven Kennedy stevenkennedy2263 at gmail.com
Tue Jun 21 22:51:43 CEST 2011


You need:
mydata$apples<-as.numeric(mydata$apples)


On Wed, Jun 22, 2011 at 6:38 AM, Alina Sheyman <alinashe at gmail.com> wrote:
> I'm trying to convert data from character to numeric.
>
>  I've imported data as a csv file, I'm assuming that the import is a
> database - are all the columns in  a database considered "vectors"  and that
> they can be  operated on individually
> Therefore I've tried the following
> mydata <- as.numeric(mydata$apples)
>
> when i then look at mydata again  the named column is still in "character"
> format
>  if i do mydata2 <- as.numeric(mydata$apples)
> the new object mydata2 is empty.
>
> Am i missing something about the structure of R?
>
> alina
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list