[R] problems with read.csv

David Winsemius dwinsemius at comcast.net
Mon Nov 2 22:43:50 CET 2009


On Nov 2, 2009, at 4:09 PM, Fang (Betty) Yang wrote:

> Dear all,
>
> I'd like to ask help on R code to get the same results as the  
> following
> Splus code:
>
>> indata<-importData("/home/data_new.csv")
>
>> indata[1:5,4]
>
> [1] 0930 1601 1006 1032 1020
>
> I tried the following R code:
>
>> indata<-read.csv("/home/data_new.csv")

Do you get what you desire with setting as.is=TRUE?

indata<-read.csv("/home/data_new.csv", as.is=TRUE )

Also see the colClasses arguments in read.xxx functions.


>> indata[1:5,4]
>
> [1]  930 1601 1006 1032 1020
>
> I'd like the first one to be 0930, too.
>

So you want the strings (aka "character" vectors) to stay strings.
-- 

David Winsemius, MD
Heritage Laboratories
West Hartford, CT




More information about the R-help mailing list