You need to use the fill argument in the read.table function. Suppose I have the following file
"A","B","C" 1,2,3 4,5 6,7,8
called tmp.txt . Note that line 2 has only two values. Then
> a = read.table("tmp.txt", sep=",", header=TRUE, fill=TRUE) > a ABC 1 1 2 3 2 4 5 NA 3 6 7 8
You use standard configuration commands to remove (if you want) any lines containing NA :
> a[!is.na(a$C),] ABC 1 1 2 3 3 6 7 8
csgillespie
source share