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

Gregory, Matthew matt.gregory at oregonstate.edu
Tue Jul 1 19:41:23 CEST 2008


Hi James and all,

James Gibbons wrote:
> I don't use RPy but I would guess this should be something like
> 
> model = r.formula("spp ~ ANNPRE + ANNTMP + DEM + SLPPCT")

Thanks to all (offline and online) for suggesting solutions for this
problem.  My problem was that the names of my data frames (spp, env)
were not being 'seen' by R as valid objects when using the formula
version of cca (cca.formula).  Deep within this function, there is a
call to eval.parent() and 'spp' was not being recognized as a valid
name.

Through some examples on the RPy wiki
(http://rpy.wiki.sourceforge.net/Manual+-+Linear+modeling), it appears
that it is sometimes necessary (especially with formulae?) to register a
name with the object by using R's assign.  When I added the below code,
everything worked spendidly.

  r.assign('spp', spp)
  r.assign('env', env)
  model = r("spp ~ ANNPRE + ANNTMP + DEM + SLPPCT")
  out_cca = r.cca(model, env)

Again, thanks for the helpful suggestions for a newbie R user.

matt



More information about the R-sig-ecology mailing list