Error while reading csv file using read.table function in R

r

#1

I am currently studying about how to load data in R while studying I came across a function read.table in R .I have used this function to load one file which gives me an error .I want to know how I can remove this error.

train <- read.table("train_loan.csv")
Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,  : 
  line 1 did not have 2 elements

#2

@harry,

The problem may be due to unequal number of elements in each row in the data frame returned by using read.table. You can try using the argument “fill=TRUE” in your command like this ->

train <- read.table(“train_loan.csv”, fill=TRUE)

If you still face a problem refer to this link

http://stackoverflow.com/questions/19455070/confusing-error-in-r-error-in-scanfile-what-nmax-sep-dec-quote-skip-nli

Hope this helps!