Python 集成 R 语言 - PyThor

jopen 8年前

RPy2 可以在 Python 和 R 之间进行交互,让用户可以在 Python 中轻松的使用 R 的封装包。

Python 一般用来进行数据分析,但是许多的包只存在于 R 语言中。所以,在 Python 与 R 中进行互通非常重要。

Pythor 包含使用 RPY2 的方法,还可以编写 R 包的封装。

线性模型的 R 代码示例:

fit <- lm('eruptions ~ waiting', data=faithful_geyser)  predicted <- predict(fit, newdata=tail(faithful_geyser))

使用 Pythor 之后的 Python 代码:

pylm = PYLM()  relationship='eruptions~waiting'  pylm.fit(relationship, faithful_pandas_df)  pylm.predict(faithful_pandas_df.tail(5))

官方网站:http://www.open-open.com/lib/view/home/1452215870714