Dear all, I try to use read.table to get the data from a tab delimited file, and some of the data is shown below: 3185 heterogeneous nuclear ribonucleoprotein F 3187 heterogeneous nuclear ribonucleoprotein H1 (H) 3188 heterogeneous nuclear ribonucleoprotein H2 (H') 3189 heterogeneous nuclear ribonucleoprotein H3 (2H9) 3190 heterogeneous nuclear ribonucleoprotein K /// heterogeneous nuclear ribonucleoprotein K 3190 heterogeneous nuclear ribonucleoprotein K 3309 "heat shock 70kDa protein 5 (glucose-regulated protein, 78kDa)" 3310 heat shock 70kDa protein 6 (HSP70B') 3312 heat shock 70kDa protein 8 3313 heat shock 70kDa protein 9B (mortalin-2) 6302 sarcoma amplified sequence 6303 spermidine/spermine N1-acetyltransferase 6304 special AT-rich sequence binding protein 1 (binds to nuclear matrix/scaffold-associating DNA's) 6305 SET binding factor 1 6307 sterol-C4-methyl oxidase-like 6625 Small nuclear ribonucleoprotein 70kDa polypeptide (RNP antigen) 6626 small nuclear ribonucleoprotein polypeptide A 6627 small nuclear ribonucleoprotein polypeptide A' 6628 small nuclear ribonucleoprotein polypeptides B and B1 6629 Small nuclear ribonucleoprotein polypeptide B'' when I use> test <- read.table("data.txt", colClasses = "character", sep="\t")I found out that "test" only has certain records: 3185 heterogeneous nuclear ribonucleoprotein F 3187 heterogeneous nuclear ribonucleoprotein H1 (H) 3188 heterogeneous nuclear ribonucleoprotein H2 (H') 3312 heat shock 70kDa protein 8 3313 heat shock 70kDa protein 9B (mortalin-2) 6302 sarcoma amplified sequence 6303 spermidine/spermine N1-acetyltransferase 6304 special AT-rich sequence binding protein 1 (binds to nuclear matrix/scaffold-associating DNA's) 6628 small nuclear ribonucleoprotein polypeptides B and B1 6629 Small nuclear ribonucleoprotein polypeptide B'' and it means that whenever read.table reads ' , it skips the next line, until it reads ' again.... Could anyone show me how to solve this kind of problem ? I greatly appreciate for any suggestion. Thanks. Alex Tsoi- [[alternative HTML version deleted]]
use quote="" to disable the effect of ' cheers Ben Bolker
On May 22, 2007, at 9:41 PM, Alex Tsoi wrote:> Dear all, > > I try to use read.table to get the data from a tab delimited file, > and some > of the data is shown below:[snip]> > and it means that whenever read.table reads ' , it skips the next > line, > until it reads ' again.... > > Could anyone show me how to solve this kind of problem ? > > I greatly appreciate for any suggestion. Thanks.You might want to have a look at ?read.table for more details, but the following should do it: test <- read.table("data.txt", colClasses = "character", sep="\t", quote="\"") Essentially by default read.table sees both " and ' as quote delimiters. In your data, you only want " as a quote delimiter.> Alex Tsoi-Haris Skiadas Department of Mathematics and Computer Science Hanover College