Re: [R] Newbie problem with read.table

From: Marc Schwartz <MSchwartz_at_mn.rr.com>
Date: Wed 12 Oct 2005 - 22:48:53 EST

On Wed, 2005-10-12 at 14:31 +0200, Jan Conrad wrote:
> Hi R,
> I have a seemingly simple problem. I have a table in following format
> (tab seperated)
>
> Njets NBjets NElec NMuon Meff HT HT3j HE Aplan
> Plan
> 1 4 3 2 0 366.278 253.642 87.7473 1385
> 0.0124566 0.376712
> 2 3 1 1 0 235.19 157.688 18.2852
> 574.253 0.00064187 0.00528814
>
> I read in with:
>
> > ttbar<-read.table("test2.dat",header=TRUE)
>
>
> > ttbar
> Njets NBjets NElec NMuon Meff HT HT3j HE Aplan
> 1 4 3 2 0 366.278 253.642 87.7473 1385.000 0.01245660
> 2 3 1 1 0 235.190 157.688 18.2852 574.253 0.00064187
> Plan
> 1 0.37671200
> 2 0.00528814,
>
> i.e.. the table is split after 9 variables. How come ?
>
> Thanks,
> Jan

As per ?read.table, the default delimiter is 'sep = ""', which is any "whitespace".

Hence, if your file is tab delimited, you need to modify your call to:

  ttbar <- read.table("test2.dat", header = TRUE, sep = "\t")

HTH, Marc Schwartz



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 Received on Wed Oct 12 23:02:27 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 18:47:28 EST