Re: [R] How to convert Charagter variables into numeric

2009-02-06 Thread John Fox
gt; Behalf Of Arup > Sent: February-06-09 1:51 AM > To: r-help@r-project.org > Subject: [R] How to convert Charagter variables into numeric > > > I am importing a dataset in R where some of the variable are numerical and > some of them are character...but the problem is that R i

Re: [R] How to convert Charagter variables into numeric

2009-02-06 Thread Marc Schwartz
There is an issue that is being overlooked here. The read.table() family of functions use type.convert() by default internally to determine the resultant data types of the columns going into the data frame from the source text file. Everything read in by read.table() starts as character and then t

Re: [R] How to convert Charagter variables into numeric

2009-02-06 Thread Wacek Kusnierczyk
if you use read.table for the import, reading about the colClasses parameter in ?read.table may help. vQ > On Thu, 5 Feb 2009 22:50:38, wrote: > > >> I am importing a dataset in R where some of the variable are numerical >> > and > >> some of them are character...but the problem is t

Re: [R] How to convert Charagter variables into numeric

2009-02-06 Thread Karina Knaus
You might want to try as.numeric(X), if you want to convert a factor then you could use as.numeric(as.character(X)), where X is a "variable". Karina On Thu, 5 Feb 2009 22:50:38, wrote: > I am importing a dataset in R where some of the variable are numerical and > some of them are character

[R] How to convert Charagter variables into numeric

2009-02-05 Thread Arup
I am importing a dataset in R where some of the variable are numerical and some of them are character...but the problem is that R is treating numerical variables as character (I am using "is.character" to judge the type). Now the question is how can I convert these character variables into numeri