On Thu, Nov 12, 2009 at 2:30 PM, Nick Schurch <n.schu...@dundee.ac.uk> wrote: > OK, I'm still having issues with a related problem to the one I had before. > > The R package pvclust produces a list object. One of the entries in it is > ...$hclust$labels. I want to replace this with a list of my own and then > feed it inot another r package. In R I would do... > > results=pvclust(mydata, method.hclust="complete", method.dist="euclidean", > nboot=100) > results$hclust$labels = seq(1,50) > sigresults = pvpick(results, alpha=0.68, pv="au", type="geq", max.only=TRUE) > > In rpy I'm having problems doing this. Running the clustering is fine: > > results = r.pvclust(data=mydata, method_hclust="complete", > method_dist="euclidean", nboot=100) > > but I don't know how to get at the '$hclust$labels' entry inside the robj it > creates! I can convert "results" back to a python object, edit it, and then > convert it back into an R object to feed into pvpick, but when I try this > somthing isn't right about the conversion back and it falls over. There > must be a way to edit the robj without requiring a conversion... This really > should be simple - I'm amazed that it isn't; or am I missing something.
It isn't elegant (rpy2 offers some nice approaches here), but for rpy1 I would use the "execute an R command string" trick: r("results$hclust$labels = seq(1,50)") or r("results$hclust$labels <- seq(1,50)") This assumes the variable "results" existing in the R name space (and not just in the Python namespace). You may need to assign it first, rpy.r.assign("results",results) Note I have not tested this as your example was not self contained (it needs a suitable example dataset - R comes with lots). Peter ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ rpy-list mailing list rpy-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rpy-list