作者celestialgod (天)
看板R_Language
标题[情报] Hadley新套件 purrr
时间Fri Oct 2 14:05:19 2015
[关键字]: Hadley, purrr
[出处]:
http://www.r-bloggers.com/purrr-0-1-0/
https://github.com/hadley/purrr
[重点摘要]:
Installation:
Get the released version from CRAN:
install.packages("purrr")
Or the development version from github with:
# install.packages("devtools")
devtools::install_github("hadley/purrr")
example:
library(purrr)
mtcars %>%
split(.$cyl) %>%
map(~ lm(mpg ~ wt, data = .)) %>%
map(summary) %>%
map_dbl("r.squared")
# 4 6 8
# 0.5086326 0.4645102 0.4229655
# 依照cyl不同做不同的回归,print每一个模型的R^2
更多例子请参考上方连结
r-blogger那篇的Purrr and dplyr
那个cv code变的很漂亮XD dplyr不足的地方都被补足了!
有空要来做新的教学了XDD
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 140.109.73.190
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/R_Language/M.1443765922.A.4AB.html
※ 编辑: celestialgod (140.109.73.190), 10/02/2015 14:22:42
1F:推 Wush978: 感谢分享 10/02 18:36
2F:推 andrew43: 有用有用! 10/02 18:59
3F:推 obarisk: 这取名是@@ 10/02 19:34
4F:推 sacidoO: 感谢分享 10/06 07:44