[R-sig-eco] Model specification with RPy/vegan integration (Gregory, Matthew)

James Gibbons j.gibbons at bangor.ac.uk
Tue Jul 1 17:32:56 CEST 2008


> 
> Hi all,
> 
> (This might be a bit tangetial and technical question for this
> listserve.  Please advise if there is a more appropriate venue.)
> 
> I'm trying to call vegan 'cca' from Python using Rpy.  I read my species
> and environmental data into R data frames without an issue and can even
> run the 'full' cca model without a problem, e.g. 
> 
>   from rpy import *
>   set_default_mode(NO_CONVERSION)
> 
>   # Import the vegan library
>   r.library('vegan')
> 
>   # Open up the data files and read into data frames
>   spp_file = r.read_csv('spp.csv', header=r.TRUE)
>   env_file = r.read_csv('env.csv', header=r.TRUE)
>   spp = r.data_frame(spp_file, row_names='FCID')
>   env = r.data_frame(env_file, row_names='FCID')
> 
>   # Squareroot transform the species matrix
>   spp = r.sqrt(spp)
> 
>   # Create the vegan CCA
>   out_cca = r.cca(spp, env)
> 
> However, when I try to specify the model to only include a subset of the
> environmental variables, e.g.
> 
>   # Create the vegan CCA
>   model = r("spp ~ ANNPRE + ANNTMP + DEM + SLPPCT")

I don't use RPy but I would guess this should be something like

model = r.formula("spp ~ ANNPRE + ANNTMP + DEM + SLPPCT")


>   out_cca = r.cca(model, env)
> 
> I get the error "Error in eval(expr, envir, enclos) : object "spp" not
> found".  Note that running the subsetted model in the R console works
> correctly as expected.  Furthermore, I can run example code from the RPy
> pages which uses the '~' notation to specify models and it works
> correctly as well.  I'm sure I have a silly little syntax error, but I'm
> just not seeing it.
> 
> Thanks for help,
> matt
> 
> 
> 
> ------------------------------
> 
> _______________________________________________
> R-sig-ecology mailing list
> R-sig-ecology at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
> 
> 
> End of R-sig-ecology Digest, Vol 4, Issue 1
> *******************************************


-- 
Gall y neges e-bost hon, ac unrhyw atodiadau a anfonwyd gyda hi,
gynnwys deunydd cyfrinachol ac wedi eu bwriadu i'w defnyddio'n unig
gan y sawl y cawsant eu cyfeirio ato (atynt). Os ydych wedi derbyn y
neges e-bost hon trwy gamgymeriad, rhowch wybod i'r anfonwr ar
unwaith a dilëwch y neges. Os na fwriadwyd anfon y neges atoch chi,
rhaid i chi beidio â defnyddio, cadw neu ddatgelu unrhyw wybodaeth a
gynhwysir ynddi. Mae unrhyw farn neu safbwynt yn eiddo i'r sawl a'i
hanfonodd yn unig  ac nid yw o anghenraid yn cynrychioli barn
Prifysgol Bangor. Nid yw Prifysgol Bangor yn gwarantu
bod y neges e-bost hon neu unrhyw atodiadau yn rhydd rhag firysau neu
100% yn ddiogel. Oni bai fod hyn wedi ei ddatgan yn uniongyrchol yn
nhestun yr e-bost, nid bwriad y neges e-bost hon yw ffurfio contract
rhwymol - mae rhestr o lofnodwyr awdurdodedig ar gael o Swyddfa
Cyllid Prifysgol Bangor.  www.bangor.ac.uk

This email and any attachments may contain confidential ...{{dropped:14}}



More information about the R-sig-ecology mailing list