在 R 中的 map() 中使用管道
Using pipes within map() in R
尝试在 map() 中进行管道传输时出现意外结果
map(ls(), ~ . %>% get %>% dim)
returns以下留言:
Functional sequence with the following components:
1. get(.)
2. dim(.)
Use 'functions' to extract the individual functions.
我真的不知道 functions() 如何让我得到我想要的结果。
有没有办法用管道和地图做到这一点?
不使用管道,
map(ls(), ~ get(dim(.)))
,结果如我所料。
. %>% get %>% dim
已经是一个函数,所以只需省略 ~
,即
map(ls(), . %>% get %>% dim)
或:
ls() %>% map(. %>% get %>% dim)
尝试在 map() 中进行管道传输时出现意外结果
map(ls(), ~ . %>% get %>% dim)
returns以下留言:
Functional sequence with the following components:
1. get(.)
2. dim(.)
Use 'functions' to extract the individual functions.
我真的不知道 functions() 如何让我得到我想要的结果。
有没有办法用管道和地图做到这一点?
不使用管道,
map(ls(), ~ get(dim(.)))
,结果如我所料。
. %>% get %>% dim
已经是一个函数,所以只需省略 ~
,即
map(ls(), . %>% get %>% dim)
或:
ls() %>% map(. %>% get %>% dim)