I'm new to R and I'm trying to read a tsv file where sometimes there is a "#" in the table. R just stopped reading when coming across the "#" and gave me the error:

    Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,  : 
    line 6227 did not have 6 elements

I looked at that line in the file and I found the "#". The data looks like this:

    CM School Supply #1    Upland     CA    3   8    Shopping

When I delete it R can continue reading the table,but I have more "#"s in the file...

How to set the variables in the read.table()? I tried to search for a solution everywhere but failed... Hope someone here can help me out. Thanks!

有帮助吗?

解决方案

You can completely turn off read.table()'s interpretation of comment characters (by default set to "#") by setting comment.char="" in your call to read.table().

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top