[R] Question about Structure

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Thu Mar 25 15:33:35 CET 1999


"Partha Bagchi" <Partha_Bagchi at hgsi.com> writes:

> Hello,
> Perhaps I am missing something here about the function structure() (Platfrm etc.
> in the end?
> 

Nope. You're missing something about the ":" operator

> > structure(1:3, dim= 3:1)
> Error: dim<- length of dims do not match the length of object

1:3 == c(1,2,3)
3:1 == c(3,2,1)

dim=3:1 means you want this as a 3x2x1 array, 6 cells in total, but 3 data.

> > structure(1:3, dim= 1:3)
> Error: dim<- length of dims do not match the length of object

1x2x3-array...

> > structure(1:4, dim= 2:2)
> Error: dim<- length of dims do not match the length of object

2:2 = from 2 to 2 step 1 = 2

2-array, four values

> > structure(1:4, dim= 1:4)
> Error: dim<- length of dims do not match the length of object

1x2x3x4 array, 24 cells, four values.

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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