[R] ' quote problem in reading lots of files at once

From: Srinivas Iyyer <srini_iyyer_bio_at_yahoo.com>
Date: Mon 11 Sep 2006 - 16:35:38 GMT

Dear group,
 i have 114 files (all have 5 columns) and variable number of rows.

I want to read all the files and select the first column and 4th column and fill the values into a big matrix. I have a pre-made matrix that would have all rownames (1st column) and coloumn names (4th column from file to be read).

mymat <- matrix(data = 1, nrow = length(gomfs), ncol = length(x))

# here gomfs is a large set of rownames from the files to be read.
# x (114 files)

for(i in x){

        xa <- read.table(i,sep='\t')
        a2 <- as.character(xa[,1])
        a3 <- xa[,4]
        nd <- data.frame(a2,a3)
        tarmat[a2,i] = a3


What is the problem then:

The problem is a2 has ' (single quotes). So when a2 does not have singles quote, everything works fine. But when a2 has ' - then starting from there to the EOF all values are cluttered.


> a2[49]

[1] "mRNA guanylyltransferase activity"

> a2[50]

[1] "polynucleotide 5-phosphatase
activity\t1\t1\t0.0160650535501781\t0.0160650535501781\t0.0664390950962566\nribulose-phosphate 3-epimerase

How can I escape the ' quote character when I read each file. So that I do not have the problem of clutter and my matrix is read well.

Thank you.

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Tue Sep 12 20:05:31 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 12 Sep 2006 - 10:30:04 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.