[R] Problem labeling arrays

From: downunder03 <larsfromspace_at_web.de>
Date: Tue 02 Jan 2007 - 22:50:30 GMT

Hi all. I'am sitting for hours. I have a problem labelling arrays. I am loosing labels for higher dimensions than matrices. Has anyone already faced that problem? There must be some direct way without writing complicated functions. Thanks for any hint. greetings lars

dimnames(x)[[2]]<-c("F1_5", "F2_5", "F3_5","F4_5", "F5_5","F6_5", "F7_5", "F8_5", "F9_5")

partialCorr <- function (cond, mat)

        cor(qr.resid(qr(cbind(1, mat[, cond])), mat[, -cond]))

# matrix keep label


# array looses label

bsp1 <- array(0, c(7,7,36))
k <- 0
for(i in 1:8) for(j in (i+1):9) {

    k <- k+1
    bsp1[, , k] <- partialCorr(c(i, j), x) }
# I tried something to label inside the loop
bsp1 <- array(0, c(7,7,36))
k <- 0
for(i in 1:8) for(j in (i+1):9) {

    k <- k+1
    bsp1[, , k] <- partialCorr(c(i, j), x)     dimnames(bsp1[,,k])=dimnames(partialCorr(c(i,j), x)) }
# I tried something to label outside the loop but can't directy adress the
labels <- array(0, c(7,1,36))
k <- 0
for(i in 1:8) for(j in (i+1):9) {

    k <- k+1
    labels[, , k] <- as.vector(rownames(partialCorr(c(i,j), x))) }
for (k in 1:36){
dimnames(bsp1[,,k])=list(c(labels[,1,k]),c(labels[,1,k])) }

View this message in context: http://www.nabble.com/-R--Problem-labeling-arrays-tf2910585.html#a8132366
Sent from the R help mailing list archive at Nabble.com.

R-help@stat.math.ethz.ch mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Wed Jan 03 09:56:13 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 02 Jan 2007 - 23:30:29 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.