[R] Separator argument in read.table

Rolf Turner r.turner at auckland.ac.nz
Thu May 29 04:05:52 CEST 2008


On 29/05/2008, at 1:48 PM, Gundala Viswanath wrote:

> Hi,
>
> Suppose I have the following tabular data:
>
>
> 1729_at | TRADD | TNFRSF1A-associated via death domain | protein- 
> coding
> 1773_at | FNTB | farnesyltransferase, CAAX box, beta | protein-coding
> 177_at | PLD1 | phospholipase D1, phosphatidylcholine-specific |  
> protein-coding
>
>
> What is the right separator used for read.table function?
>
> I tried this:
>
> dat <- read.table("geo2geneinfo_bymodel.txt", sep = "|")
> print(dat)
>
> It doesn't seem to work. It flattens the table above into just two  
> columns
> meaning only contain $V1 and $V2.
>
> sep=" | "  also won't work.

I created a test file ``gorp'':

$ cat gorp
1 | 2 | 3
4 | 5 | 6
7 | 8 | 9

I then (in R) did

  > gorp <- read.table("gorp",sep="|")

and got
  > gorp
   V1 V2 V3
1  1  2  3
2  4  5  6
3  7  8  9

No problema.  I then copied and pasted your sample data into a file  
``mung'' and did

  > mung <- read.table("mung",sep="|")

and got

  > mung
         V1      V2                                               V3
1 1729_at   TRADD             TNFRSF1A-associated via death domain
2 1773_at    FNTB              farnesyltransferase, CAAX box, beta
3  177_at    PLD1   phospholipase D1, phosphatidylcholine-specific
                V4
1  protein-coding
2  protein-coding
3  protein-coding

Again, no problema.  So there's something funny about your system, or  
there are non-printing
characters in your data file which did not show up in the sample  
lines of the data file that
you posted.  Or ``they'' are just out to get you! :-)  (I know the  
feeling ....)

	cheers,

		Rolf Turner


######################################################################
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}



More information about the R-help mailing list