This is a test version of Biostars. For the public version, visit https://www.biostars.org.
R: Error In Scan ... Line 7 Did Not Have 3 Elements

Hi, i'm trying to normalize my data but i get the following error:

celfiles <- read.affy(covdesc="silke.txt", path="data")
Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,  : 
  line 7 did not have 3 elements

my txt file seems to be normal. I already searched for answers, but i don't know where i made a mistake

Thanks!!

r affymetrix

Hi Silke, please follow the guidelines for submitting an error in R:

  • post the output of traceback()
  • post a reproducible example (silke.txt, it is most likely the source of error)
  • post the output of sessionInfo()

Thanx!

This error means what it says; the text file is not (tab) delimited in the way that you think. Most often this happens when lines contain comment characters (#) or single quotes. Read the help page for read.table() for ways to deal with this.

Please, post your solution.

Yes, please do. The point of this site is to provide answers for everyone. This post is not an answer.

Hello silkeverhelle!

We believe that this post does not fit the main topic of this site.

No longer relevant.

For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.

If you disagree please tell us why in a reply below, we'll be happy to talk about it.

Cheers!

This error is pretty self-explanatory. There seem to be data missing in the first line of your data file (or second line) Also, just check your header. Make your header single word. Also, you can use

read.table("test.txt", header = TRUE, fill = TRUE)

This is a 5+ year old post that was closed 2+ years ago. Why dig it up and add a comment?

1 answer

Here are the solutions:

You could have also set read.table(..., comment.char = "") to turn off the interpretation of comments in the file.
Apostrophies can also cause it ( ' ). Fix this by setting the option quote = "\""

from Rich Scriven .

Sometimes I also find it helpful to force the read with 'fill = T'. eg: read.table(..., comment.char = "", fill=T) Then I look at the resulting table to see which lines are tripping it up. Often times it's comments as those above have pointed out, or not designating the header/colnames propoerly. .

Log in to answer this question.