[R] Naming dimnames in an array using the results of an expression
Dr Bob Phillips
bob.phillips at york.ac.uk
Tue May 22 19:22:53 CEST 2012
dear all
i'm struggling with naming in an array
diag.data is one of a series of 2x2 diagnostic testing arrays, with
'Outcome' columns (true/false) and 'Test' rows (High-risk, Low-risk),
drawn from a larger list object of 'results'
i can hard-code the names of the array using dimnames;
diag.data<-array(c(19,2,125,50),c(2,2)) #example to run - actually comes
out with rownames/colnames already attached
dimnames(diag.data)<-list(Rule=c("LR","HR"),Outcome=c("FALSE","TRUE"))
but i would really love to be able to soft-code it, using the different
'rule' names and slightly different 'outcomes' as extracted from the
main list of results, rather than just 'rule' and 'outcome' e.g.
dimnames(diag.data)<-list(names(result[1])=rownames(diag.data),names(result[[1]][2])=colnames(diag.data))
this doesn't work
i understand that the dimnames command is NOT executing the function
'names' and giving me the result of this, and have struggled and failed
to use the 'eval' expression with alternative environments (which i
don't understand ...)
can anyone assist?
cheers - bob
--
Dr Bob Phillips
MRC Research Training Fellow
CRD
University of York
York
YO10 5DD
t: +44 (0)1904 321099
f: +44 (0)1904 321041
e: bob.phillips at york.ac.uk
www.york.ac.uk/inst/crd
www.crd.york.ac.uk/prospero
CRD is part of the National Institute for Health Research and is a
department of the University of York.
EMAIL DISCLAIMER: http://www.york.ac.uk/docs/disclaimer/email.htm
More information about the R-help
mailing list