Skip to content

trouble with data.matrix

3 messages · Martin Maechler, Laurent Gautier

#
Dear all,


The following causes me trouble:
`data.frame':	4 obs. of  3 variables:
 $ X2.5: int  2 3 4 5
 $ X3.6: int  3 4 5 6
 $ X4.7: int  4 5 6 7
int [1:4, 1:3] 2 3 4 5 3 4 5 6 4 5 ...
 - attr(*, "dimnames")=List of 2
  ..$ : chr [1:4] "1" "2" "3" "4"
  ..$ : chr [1:3] "X2.5" "X3.6" "X4.7"



Reading the man page for 'data.matrix' trends to indicate it generates a
numerical matrix from a data.frame.
... or am I wrong ? (I could almost swear it was working before... but
like always the question turns to be
'before what ?'   =)    ).



Any hint would be greatly appreciated







...Oups, I almost forget:
I use R-1.3.1 compiled on a linux box with Suse 7.1






Laurent
#
Laurent> Dear all, The following causes me trouble:

	> a <- data.frame(2:5,3:6,4:7)

	> str(a)
	`data.frame':	4 obs. of  3 variables:
	 $ X2.5: int  2 3 4 5
	 $ X3.6: int  3 4 5 6
	 $ X4.7: int  4 5 6 7

	> str(data.matrix(a))
	 int [1:4, 1:3] 2 3 4 5 3 4 5 6 4 5 ...
	 - attr(*, "dimnames")=List of 2
	  ..$ : chr [1:4] "1" "2" "3" "4"
	  ..$ : chr [1:3] "X2.5" "X3.6" "X4.7"

    Laurent> Reading the man page for 'data.matrix' trends to indicate it
    Laurent> generates a numerical matrix from a data.frame.  

exactly --- and what is the trouble ?
You *did* get a numerical matrix {integers are numeric}

    Laurent> ... or am I wrong ? (I could almost swear it was working
    Laurent> before... 

(still is)

Martin Maechler <maechler at stat.math.ethz.ch>	http://stat.ethz.ch/~maechler/
Seminar fuer Statistik, ETH-Zentrum  LEO D10	Leonhardstr. 27
ETH (Federal Inst. Technology)	8092 Zurich	SWITZERLAND
phone: x-41-1-632-3408		fax: ...-1228			<><
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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 Sat, 27 Oct 2001, Martin Maechler wrote:

            
Ouch...hhmmmm... I think I know: lack of sleep.....
I was looking the 'attribute' line... too stoopid....


Sorry for bothering (and eventually making a fool of myself)....




Laurent





-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._