How to skip invalid rows when reading data frame from file in R?
dataframe, r
Solution
using @PaulHiemstra's sample data:
read.table("test.csv", sep = ";", fill=TRUE)
then you take care of the NAs as you wish.
Problem
I have a large file which contains lots of data, and I'd like to read it into dataframe, but found some invalid rows. These invalid rows cause the read.table to break. I try the following method to skip invalid lines, but it seems the performance is very bad. ``` counts<-count.fields(textConnection(lines),sep="\001") raw_data<-read.table(textConnection(lines[counts == 34]), sep="\001") ``` Is there any better way to achieve this? Thanks