[英]How to combine pipes and purrr with {} syntax
I am writing a complex function, but conceptually it is equivalent to 我正在编写一个复杂的函数,但从概念上讲,它等效于
A <- 1:3
B <- 10:12
A %>% {purrr::map(B, ~.+.x)}
where, in my logic, .
在那里,在我的逻辑.
should be A
and .x
should be B
应该是A
和.x
应该是B
The methodology above returns c(20, 22, 24)
while I want to get c(11, 13, 15)
. 上面的方法返回c(20, 22, 24)
而我想得到c(11, 13, 15)
。
How do you combine pipes pointing to the lambda function in purrr? 如何在purrr中组合指向lambda函数的管道?
(Please don't suggest me A %>% +B
;-)) (请不要建议我A %>% +B
;-))
purrr::map2(A, B, ~ .x + .y)
是您需要的
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.