On Aug 8, 7:54 am, kcrisman <kcris...@gmail.com> wrote: > On Aug 7, 4:02 pm, Brad <brad.reisf...@gmail.com> wrote: > > > Hi, > > > I just downloaded and installed v4.7 of Sage on Mac OS X 10.6.8. > > > I really like the application and appreciate all of the hard work the > > Sage team has done to produce this great software package. > > Great! > > > Lately, I have been trying to learn R and rpy2 for statistical > > analyses. > > Good. > > > Unfortunately, I have been experiencing some problems as I work > > through the rpy2 documentation pages (http://rpy.sourceforge.net/rpy2/ > > doc-2.0/html/introduction.html#getting-started) from within Sage. > > Yes, there aren't that many people using rpy2 with Sage - for > instance, William Stein found something nasty about Numpy and rpy2 not > that long ago, at least them not working together in > Sage:http://flask.sagenb.org/home/pub/57/ (I assume this worksheet still > exists?) > > > > > For instance, this simple worksheet input, > > > --------------------------------- > > import rpy2.robjects as robjects > > piplus2 = robjects.r('pi') + 2 > > --------------------------------- > > sage: piplus2 = robjects.r('pi')+int(2) > > should work. The problem is that we don't have much casting to RPy; > most of the work has gone into the R pexpect interface instead, > working directly with R. I find RPy confusing, myself :) and work > directly with R, though I do have to use r.eval("stuff") a lot for > positional arguments, which don't always work well with it. > > > --------------------------------- > > > I then switched to r mode on the worksheet and typed a set of R > > commands given in the same rpy2 documentation: > > > --------------------------------- > > ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14) > > trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69) > > group <- gl(2, 10, 20, labels = c("Ctl","Trt")) > > weight <- c(ctl, trt) > > anova(lm.D9 <- lm(weight ~ group)) > > summary(lm.D90 <- lm(weight ~ group - 1))# omitting intercept > > --------------------------------- > > Hmm, that surprises me. This should not be calling rpy2. > > I get > > Analysis of Variance Table > > Response: weight > Df Sum Sq Mean Sq F value Pr(>F) > group 1 0.6882 0.68820 1.4191 0.249 > Residuals 18 8.7293 0.48496 > > Call: > lm(formula = weight ~ group - 1) > > Residuals: > Min 1Q Median 3Q Max > -1.0710 -0.4938 0.0685 0.2462 1.3690 > > Coefficients: > Estimate Std. Error t value Pr(>|t|) > groupCtl 5.0320 0.2202 22.85 9.55e-15 *** > groupTrt 4.6610 0.2202 21.16 3.62e-14 *** > --- > Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 > > Residual standard error: 0.6964 on 18 degrees of freedom > Multiple R-squared: 0.9818, Adjusted R-squared: 0.9798 > F-statistic: 485.1 on 2 and 18 DF, p-value: < 2.2e-16 > > My guess is that you still had some residue of weirdness left over > from having imported rpy2. Try restarting the worksheet and NOT > importing rpy2. > > Good luck! We really value contributions from R users. By the way, > another open source project you may find interesting (though it > wouldn't integrate with Python/Sage) ishttp://rstudio.org/. > > - kcrisman
kcrisman, Thank you for the advice. I'll restart the worksheet and retry coding directly in R. Also, I appreciate the pointer to RStudio. -Brad -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org