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

2009-02-06 Thread John Fox
Dear Arup, It's very difficult to know what's going on without more information. What is the form of the data that you're importing and how are you reading the data? I ask because the most common way of getting data into R is probably via read.table(), which by default converts character data to f

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