Hi Barry! Thank you very much for this idea ... this is actually very useful (I am also using some hierarchical clustering, and if you want to perform the single steps for whatever reason, i.e. something like:
dist = r.dist(data, method="euclidean") hc = r.hclust(dist, method="ward") then you have to set the flag as you mentioned; because r.dist gives just the atomic list to python. So, thanks! Thomas. Barry Rowlingson wrote: >Thomas Walter wrote: > > > >>pca = r.princomp(r.t(mat), cor=True) >> >>Okay, this works. But if I want to use the predict functionality of >>princomp, like: >>pred = r.predict(pca) >> >>I obtain the following error: >> >>Traceback (most recent call last): >> File "<stdin>", line 1, in <module> >>rpy.RException: Error in UseMethod("predict") : no applicable method for >>"predict" >> >>Does anybody know how I could deal with this problem? >> >> > > This is because your 'pca' object in Python is not an R principal >components object. You need to mess with the conversion system: > > >>> pca=r('princomp(USArrests)') > >>> pca > > - a big hash/list object appears.... > > SO let's change the conversion mode: > > >>> rpy.set_default_mode(rpy.NO_CONVERSION) > >>> pca=r('princomp(USArrests,cor=TRUE)') > >>> pca ><Robj object at 0xb7d493f0> > > - now pca is a Robj this is basically the R object. So you can do: > > >>> r.predict(pca) > > but you get: > ><Robj object at 0xb7d493e0> > > which isn't very useful as is. You could reset the conversion mode, or >use r.print_(r.predict(pca)), which gives you the matrix. > >Barry > > > >------------------------------------------------------------------------- >This SF.net email is sponsored by: Microsoft >Defy all challenges. Microsoft(R) Visual Studio 2008. >http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ >_______________________________________________ >rpy-list mailing list >rpy-list@lists.sourceforge.net >https://lists.sourceforge.net/lists/listinfo/rpy-list > > -- ------------------------- Thomas Walter EMBL Heidelberg Meyerhofstrasse 1 69117 Heidelberg Germany Tel: +49 (0)6221 387-8857 ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ rpy-list mailing list rpy-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rpy-list