Skip to content
Back to formatted view

Raw Message

Message-ID: <B2E94AAE-3D6A-4307-8A2C-71DB4AE41BDA@comcast.net>
Date: 2009-11-02T21:43:50Z
From: David Winsemius
Subject: problems with read.csv
In-Reply-To: <000601ca5c00$ce174f70$6a45ee50$@yang@ualberta.ca>

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