1 Star 1 Fork 1

LuWinter/R-for-Data-Science

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Chapter 19.R 1.07 KB
一键复制 编辑 原始数据 按行查看 历史
LuWinter 提交于 2020-07-27 01:06 . R数据科学
library(modelr)
library(tidyverse)
data.frame(x = list(1:3, 3:5))
tibble(
x = list(1:3, 3:5),
y = c("1, 2", "3, 4, 5")
)
df <- tribble(
~x1,
"a,b,c",
"d,e,f,g"
)
df
df %>%
mutate(x2 = str_split(x1, ","))
df %>%
mutate(x2 = str_split(x1, ",")) %>%
unnest()
separate_rows(list("a,b,c"), sep = ",")
sim <- tribble(
~f, ~params,
"runif", list(min = -1, max = -1),
"rnorm", list(sd = 5),
"rpois", list(lambda = 10)
)
sim %>%
mutate(sims = invoke_map(f, params, n = 10))
mtcars %>%
group_by(cyl) %>%
summarise(q = list(quantile(mpg)))
probs <- c(0.01, 0.25, 0.5, 0.75, 0.99)
mtcars %>%
group_by(cyl) %>%
summarise(p = list(probs), q = list(quantile(mpg, probs))) %>%
unnest()
x <- list(
a = 1:5,
b = 3:4,
c = 5:6
)
x
df <- enframe(x)
df %>%
mutate(
smry = map2_chr(
name,
value,
~ str_c(.x, ":", .y[2])
)
)
mtcars %>%
group_by(cyl) %>%
summarise_each(funs(list))
df <- tribble(
~x,
list(a = 1, b = 2),
list(a = 2, c = 4)
)
df %>% mutate(
a = map_dbl(x, "a"),
b = map_dbl(x, "b", .null = NA_real_)
)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
R
1
https://gitee.com/luwinter/R-for-Data-Science.git
git@gitee.com:luwinter/R-for-Data-Science.git
luwinter
R-for-Data-Science
R-for-Data-Science
master

搜索帮助