[R] Two-way tables of data, etc

Murray Jorgensen maj at waikato.ac.nz
Wed Sep 5 07:16:08 CEST 2001


Suppose I have a randomized block experiment with response vector y, treatment
factor A, and block factor B. How may I print out the data in a nice two-way
array?

Here is one solution that I found (data from Steel And Torrie):

block <- gl(4,6,24)
tnames <- c("Seedling","Early", "Full", "Full/100",
          "Ripening", "Uninoculated")
treat <- gl(6,1,24,label=tnames)
content <- scan()
4.4 3.3 4.4 6.8 6.3 6.4
5.9 1.9 4.0 6.6 4.9 7.3
6.0 4.9 4.5 7.0 5.9 7.7
4.1 7.1 3.1 6.4 7.1 6.7

content <- content+30
cmat <- matrix(content,nrow=4,ncol=6,byrow=T)
dimnames(cmat) <- list(NULL,tnames)
cmat


OK, but what if I wanted to do something similar for a two-way array with
multiple observations per cell? Or present the cell means? And what about
displaying multi-way arrays of data?

Murray Jorgensen


Dr Murray Jorgensen      http://www.stats.waikato.ac.nz/Staff/maj.html 
Department of Statistics, University of Waikato, Hamilton, New Zealand 
Email: maj at waikato.ac.nz                            Fax +64-7 838 4155
Phone +64-7 838 4773 home phone +64-7 856 6705  Mobile +64-21 139 5862

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