From: Jan Conrad <Jan.Conrad_at_cern.ch>

Date: Wed 12 Oct 2005 - 23:16:06 EST

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:45:20 2005

Date: Wed 12 Oct 2005 - 23:16:06 EST

Thank you all for your answers. Yes, indeed it was only a printing
problem (in fact I had tried

the \t option before without sucess).

My first interaction with R (and the R help), I must say I am impressed.

Best,

Jan

-----Original Message-----

From: Marc Schwartz [mailto:MSchwartz@mn.rr.com]
Sent: Wednesday, October 12, 2005 3:14 PM
To: Roger.Bivand@nhh.no

Cc: Jan Conrad; r-help@stat.math.ethz.ch
Subject: Re: [R] Newbie problem with read.table

On Wed, 2005-10-12 at 14:56 +0200, Roger Bivand wrote:

> On Wed, 12 Oct 2005, 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 ?
**>
**> > options("width")
**> $width
**> [1] 80
**>
**> says what the width of your console is. Columns beyond this get
**> wrapped
**> gently (not each row by itself) - it can be set different values if
*

you

> choose - try:

*>
**> ow <- options("width")
**> options(width=40)
**> options("width")
**> ttbar
**> options(ow)
**> options("width")
**>
**> So this is just the print function for data.frame objects doing its
**> unsung job. A very useful function for looking at things when they
**> don't seem to be what you think is str(), which concisely says what
**> the structure of an object is, so str(ttbar) should tell you that it
**> is a data frame of 10 variables and 2 observations.
*

Thanks to Roger for this clarification. I took the splitting of the variables to be a consequence of the delimiter and not just a benign consequence of the printed output (at least I presume this is the proper interpretation of Jan's problem.)

The tab character is of course included in "whitespace"....using "\t" explicitly would be helpful if there is embedded whitespace (other than a tab) within a field.

Marc

<Off to get another cup of coffee....>

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:45:20 2005

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