R: Why does read.table stop reading a file?

后端 未结 1 1698
执念已碎
执念已碎 2020-12-09 19:51

I have a file, called genes.txt, which I\'d like to become a data.frame. It\'s got a lot of lines, each line has three, tab delimited fields:

mi         


        
1条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-09 20:39

    With read.table one of the default quote characters is the single quote. I'm guessing you have some unmatched single quotes in your description field and all the data between single quotes is being pooled together into one entry.

    With read.delim the defualt quote character is the double quote and thus this isn't a problem.

    Specify your quote character and you should be all set.

    > genes<-read.table("genes.txt",sep="\t",quote="\"",na.strings="-",fill=TRUE, col.names=c("GeneSymbol","synonyms","description"))
    > nrow(genes)
    [1] 42476
    

    0 讨论(0)
提交回复
热议问题