When reading in my data set in R as follows:
I get the following error message:
What does this mean and can somebody tell me how to fix it? |
||||
add a comment
|
This error is pretty self-explanatory. There seem to be data missing
in the first line of your data file (or second line, as the case may be
since you're using
header = TRUE ).Here's a mini example:
R automatically detects that it should expect rownames plus two
columns (3 elements), but it doesn't find 3 elements on line 2, so you
get an error:
Look at the data file and see if there is indeed a problem:
Manual correction might be needed, or we can assume that the value
first value in the "Second" row line should be in the first column, and
other values should be NA . If this is the case, fill = TRUE is enough to solve your problem.
R is also smart enough to figure it out how many elements it needs even if rownames are missing:
|
|||||
|
When running into this error and reviewing my dataset which appeared
to have no missing data, I discovered that a few of my entries had the
special character "#" which derailed importing the data. Once I removed
the "#" from the offending cells, the data imported without issue.
|