[R] reading csv file : blanks

Dimitri Liakhovitski ld7631 at gmail.com
Wed Apr 29 15:50:22 CEST 2009


When you read in a .csv file with some empty cells using read.csv,
there is no need to specify anything - empty cells will be recorded as
NAs automatically:

try:

data1<-read.csv("oa_2006.csv")

Dimitri


On Wed, Apr 29, 2009 at 7:54 AM, Jim Lemon <jim at bitwrit.com.au> wrote:
> Nattu wrote:
>>
>> Hi,
>>
>> I have a comma seperated data file which has blanks in it. I am trinying
>> to
>> import it to R using
>>
>> data1<-read.csv("oa_2006.csv", header = TRUE, sep = ",", quote="\"",
>> dec=".")
>>
>> I want the missing values to be "NA". instead R reads them as "U". Any
>> idea
>> why this happens ?
>>
>>
>
> Hi Nataraju,
> You have to explicitly specify the strings that you want to be read as NA
> with the na.strings argument.
>
> na.strings=""
>
> if an empty string represents NA.
>
> Jim
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Dimitri Liakhovitski
MarketTools, Inc.
Dimitri.Liakhovitski at markettools.com




More information about the R-help mailing list