RPyR语言的Python调用接口
RPy2是一个非常简单、健壮的R语言的Python调用接口。
示例代码:
import rpy2.robjects as robjects r = robjects.r ctl = robjects.FloatVector([4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14]) trt = robjects.FloatVector([4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69]) group = r.gl(2, 10, 20, labels = ["Ctl","Trt"]) weight = ctl + trt robjects.globalEnv["weight"] = weight robjects.globalEnv["group"] = group lm_D9 = r.lm("weight ~ group") print(r.anova(lm_D9)) lm_D90 = r.lm("weight ~ group - 1") print(r.summary(lm_D90))
评论