[R] Files with Missing Data - Thanks

Norman Jessup njessup at tpg.com.au
Fri Jul 2 03:59:24 CEST 2010

Thanks to Peter and Erik - This advice resolved my problem.


Norman Jessup

On 2/07/10 11:43 AM, Erik Iverson wrote:
> Norman Jessup wrote:
>> I'm a new R user so this is possibly a naive question.  I'm trying to 
>> load an external CSV file into a dataframe using:
>>   df_name<-read.table("myfile.csv")
>> myfile.csv should have 5 elements per row, though a percentage are 
>> missing the last two elements (the commas are present as 
>> placemarkers).  However, R does not create the dataset but returns 
>> the message:
>>     line 1 did not have 2 elements
>> but examining the file shows that it does.  These are the first 5 rows:
>> DARWIN,NT,800,-12.461334,130.841904
>> ALAWA,NT,810,-12.37896,130.874226
>> BRINKIN,NT,810,-12.364533,130.869394
>> CASUARINA,NT,810,-12.373112,130.883619
>> COCONUT GROVE,NT,810,-12.397685,130.852324
>> Is R complaining because the first two elements of each row are not 
>> numeric, or am I doing something else wrong?
>> Thanks for your suggestions
> You can use Peter's advice; also note there is a read.csv function.  A 
> thorough reading of the ?read.table help page is very useful I've found.
> There is also an R data import/export manual on CRAN.

More information about the R-help mailing list