Re: [R] Newbie problem with read.table

From: Roger Bivand <Roger.Bivand_at_nhh.no>
Date: Wed 12 Oct 2005 - 22:56:03 EST


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,
> Jan
>
> ______________________________________________
> 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
>

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand@nhh.no

______________________________________________
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:10:44 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:40:41 EST