[R] Separator with " | " for read.table
jholtman at gmail.com
Mon Jun 16 03:19:02 CEST 2008
Does this give you what you want:
> x <- read.table(textConnection("#GDS_ID GENE_NAME GENE_DESCRIPTION GENE_FUNCTION
+ 1007_s_at | DDR1 | discoidin domain receptor tyrosine kinase 1 |
+ 1053_at | RFC2 | replication factor C (activator 1) 2, 40kDa | protein-coding
+ 117_at | HSPA6 | heat shock 70kDa protein 6 (HSP70B') |
protein-coding"), sep="|", quote='')
V1 V2 V3
1 1007_s_at DDR1 discoidin domain receptor tyrosine kinase 1
2 1053_at RFC2 replication factor C (activator 1) 2, 40kDa
3 117_at HSPA6 heat shock 70kDa protein 6 (HSP70B')
You had a quote(') in your data; you need to have quote='' in the read.table.
On Sun, Jun 15, 2008 at 9:11 PM, Gundala Viswanath <gundalav at gmail.com> wrote:
> I have the following data file to be parsed and captured as a data frame:
> #GDS_ID GENE_NAME GENE_DESCRIPTION GENE_FUNCTION
> 1007_s_at | DDR1 | discoidin domain receptor tyrosine kinase 1 | protein-coding
> 1053_at | RFC2 | replication factor C (activator 1) 2, 40kDa | protein-coding
> 117_at | HSPA6 | heat shock 70kDa protein 6 (HSP70B') | protein-coding
> In particular it is separated by " | " , namely - space, bar, space.
> However I tried this without avail:
> geneinfo <- read.table("mydata.txt", sep=" | ", comment.char="\#")
> I also tried with sep= "|", it gave a wrong parsing. Please advice.
> - Gundala Viswanath
> Jakarta - Indonesia
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
+1 513 646 9390
What is the problem you are trying to solve?
More information about the R-help