[R] List dimention labels to plots of components

White, Charles E WRAIR-Wash DC charles.edwin.white at us.army.mil
Fri Aug 20 15:52:14 CEST 2004


My goal is more efficient code for something I anticipate doing a lot.
My example code from my first message works because I insert a seemingly
redundant recording of Dose & Treatment in the list generated in the
"by" command. Since Dose & Treatment are already recorded in the
dimensions of the list, I would like to pass those dimensions into the
function executed by lapply. That may or may not be possible.

# Append the following code to my message of 8/19
# Dose & Treatment go to list without separate user code to insert them
dat.lm2<-by(dat,list(Dose=dat$Dose,Treatment=dat$Treatment),
            function(x) lm(Response~Sex,data=x))
dimnames(dat.lm2)
dat.lm2["Low","B"]

# lapply uses dimnames to select objects but does not appear to pass 
# dimnames with object
lapply(dat.lm2,dimnames)
lapply(dat.lm2,names)
lapply(dat.lm2,function(x) print(x)[1:13])

Thanks for your help. 

Chuck




More information about the R-help mailing list