[R] Files with Missing Data

Norman Jessup njessup at tpg.com.au
Fri Jul 2 03:18:00 CEST 2010


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

regards

Norman Jessup



More information about the R-help mailing list