[R] Trouble with data dim

Clayton Springer csprin at brandybuck.ca.sandia.gov
Wed Mar 8 18:02:13 CET 2000


Dear R users,

I am a novice user working through V & R. My first question stems
from p20 of the second edition.:

I perform the following actions:

> mydata <- c(2.9,3.4,3.4,3.7,3.7,2.8,2.8,2.5,2.4,2.4)
> names(mydata) <- c('c','j','b','e','i','h','g','d','f','a')
> mydata
  c   j   b   e   i   h   g   d   f   a 
2.9 3.4 3.4 3.7 3.7 2.8 2.8 2.5 2.4 2.4 

This is good and as V & R says it should be. Then I ...

> dim (mydata) <- c(2,5)
> mydata
     [,1] [,2] [,3] [,4] [,5]
[1,]  2.9  3.4  3.7  2.8  2.4
[2,]  3.4  3.7  2.8  2.5  2.4
>
The book says I should get the additional lines:

attr(,"names")
[1] "c" "j" "b" "e" "i" "h" "g" "d" "f" "a"

What haven't I done?



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



More information about the R-help mailing list