need help with error: "more columns than column names"


I'm learning R for my new job and I'm having trouble getting past this error. The code works for my coworkers but on my end I'm getting "more columns than column names." I am on a MacBook while they are on PCs. No idea how to proceed!

here's the code:


rm(list=ls()) #clears all variables from environment --> #clears all plots/figs -->

###load data###<-"~/Desktop/LEWI_Spring2018_FishData.csv"
data.raw<-read.table("~/Desktop/LEWI_Spring2018_FishData.csv",sep=",",header=TRUE,stringsAsFactors = FALSE)

#do stuff#

###writing/exporting data###

It is not clear from the question when you get the error message - do you get it when you try to call write.table()? If so, we need more information on what you are trying to write: usually this error comes up because there is something not quite right with the separator.

apologies, the error happens when I try to 'source,' here's the error:

" Error in read.table(file = file, header = header, sep = sep, quote = quote, :
more columns than column names "

the file is an excel spreadsheet saved as a .csv

It's difficult to figure out what is wrong exactly since I cannot see your data, but it seems that the header is potentially read as one column, so there might be something wrong with the separator. Open the file you are trying to load in a text editing program to check that the separators are really commas; both for your header and your data. Does read.csv() work?

The separators are commas, yes, read.csv() does not work. Thank you for your time.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.