Skip to content

memory blues

3 messages · Laurent Gautier, Thomas Lumley, Claudia Tebaldi

#
Dear all,



I would like to know if the following behaviour is what one would expect ?
(I am running R-1.2.3 (I know I'd better upgrade) under Linux).

It seems a data.frame with only one column becomes a special case.... and
I cannot figure out why (I'd see no problem in being told to rtfm, I could not
find
anything about that in the help pages)
c.1.3.
c      1
a      2
b      3
[1] 2 3 1


...kinda odd, especially since the following give what I'd expect....
X1 X2
c  1  3
a  2  4
b  3  5
X1 X2
a  2  4
b  3  5
c  1  3



Cheers,


Laurent


--
Laurent Gautier                 CBS, Building 208, DTU
PhD. Student                    D-2800 Lyngby,Denmark
tel: +45 45 25 24 85            http://www.cbs.dtu.dk/laurent


-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://stat.ethz.ch/pipermail/r-help/attachments/20010709/8e9f5616/attachment.html
#
On Mon, 9 Jul 2001, Laurent Gautier wrote:

            
data.frame() ideally makes up names from the tags of the arguments, eg
a          b
1 1 -2.0499827
2 2 -0.4364342
3 3  0.5880059
4 4 -0.7636817
5 5 -1.3021187

If the arguments don't have tags it converts the expressions into names,
so in this example data.frame tried to convert 1:5, rnorm(5) and
rep(1,5) into valid names.
X1.5   rnorm.5. rep.1..5.
1    1 -0.5282023         1
2    2  0.6964649         1
3    3  1.1548943         1
4    4  1.3833800         1
5    5 -0.1553645         1


This approach isn't sufficient when one of the arguments to data.frame has
multiple columns. Ideally the column names of the matrix are used but if
one of the arguments is a matrix that itself has no column names then
data.frame falls back on the unimaginative "X1","X2"..

The moral of the story is that you can make up better names than
data.frame can.

	-thomas

Thomas Lumley			Asst. Professor, Biostatistics
tlumley at u.washington.edu	University of Washington, Seattle

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
On Mon, 9 Jul 2001, Laurent Gautier wrote:

            
Are you puzzled by the naming of the columns or by the loss of dimensions?
For the first you already got an explanation, but in case you are
wondering how to keep a single column of a data.frame  in the same
"ontological" category:



a[order(row.names(a)),,drop=F]  


maintains the subscripted a (assuming it is your first object, the data
frame with one column) in the data.frame class.

If you knew all this I apologize for the unwanted/unneeded lesson. 




 


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._