David,

> I am using Python 2.5 and R2.5.1
>  
> I am trying to do a simple test using the Iris data set and a regression.
>  
> Here is my code
>  
>  
> from win32com.client import Dispatch
> r=Dispatch("StatConnectorSrv.StatConnector")
> r.Init("R")
> r.Evaluate("data(iris)")
> r.Evaluate("iris.lm <- lm(Sepal.Length ~ Sepal.Width, data = iris)")
>  
>  
> If I do the above in R command line it works fine.  In Python I get nasty 
> little errors and don't know why.  WHen I do a print 
> print "Objects= ", r.Evaluate("objects()") command I see the iris data set is 
> loaded.....the regression just does not work...but as mentioned...same code 
> works in R command line.
>  
> What is going on or am I missing some additional initializations?

lm() returns an object of class "lm", which cannot be transferred
directly using Evaluate(). Use EvaluateNoReturn() instead of Evaluate()
and use Evaluate() to retrieve the transferrable parts of "iris.lm",
e.g.  r.Evaluate("iris.lm$coefficients")

Thomas
_______________________________________________
Rcom-l mailing list
Rcom-l@mailman.csd.univie.ac.at
http://mailman.csd.univie.ac.at/mailman/listinfo/rcom-l
More information (including a Wiki) at http://rcom.univie.ac.at

Reply via email to