Hi All, I have tried to find an answer within documentation, but I cannot:
o How can call a class "slot" without knowing the name a priori? E.g., let's say I use the "pcaMethods" library to create a "pcaRes" object. How can I call parts of that object without using the specific names of the object in the call? example code: library(pcaMethods) myMatrix <- matrix(runif(1e4), ncol=100) ## silly, but sufficient for example myPCA <- pca(myMatrix) ## creates a "pcaRes" S4 class for (i in slotNames(myPCA) ) { summary(myPCA@i) ### I know this doesn't work, but this is the question... what grammar could I use? } ################ I would like to be able to print out the summary for each of the components of the class "pcaRes" without knowing a priori the names of those components. I could, for example in the above case, type in summary(myPCA@completeObs) to get a summary of the input matrix. But I HAVE TO TYPE "@completeObs". In the non-S4 world, I could type myPCA[[i]] for lists, where "i" could be looping through either the list names, or the list indices. Similarly, I could type myPCA[i] for arrays, where "i" again can be either a numeric index or the name. Without this ability to identify portions within an array / loop context, it becomes exceedingly difficult to work in "S4 land". How is this sort of thing done? Thank you! Mike --- XKCD <http://www.xkcd.com> [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.