[R] read.table as integer

David Winsemius dwinsemius at comcast.net
Fri Jan 13 15:15:57 CET 2012


On Jan 13, 2012, at 7:02 AM, Francisco wrote:

> Hello,
> I have a csv file with many variables, both characters and integers.
> I would like to load it on R and do some operations on integer  
> variables, the problem is that R loads the entire dataset  
> considering all variables as characters, instead I would like that R  
> makes the distinction between the two types, because there are too  
> many variables to do:
> x1<-as.integer(x1)
> x2<-as.integer(x2)
> x3<-as.integer(x3)
> ...
>
> I tried to specify read.table(... stringsAsFactors=FALSE) but it  
> doesn't work.

You need to use colClasses

-- 
David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list