Integrate with magrittr
Opened this issue · 1 comments
ramhiser commented
Iterators and itertools2
will be more flexible and useful if they can be used with magrittr
pipes (and ultimately with dplyr
). It turns out that pipes do, in fact, work in some cases.
Example (related to #41):
as_vector <- function(x) {
unlist(as.list(x))
}
set.seed(42)
irep(function(x) rnorm(1), times=10) %>% as_vector
# [1] 1.37095845 -0.56469817 0.36312841 0.63286260 0.40426832 -0.10612452 1.51152200 -0.09465904
# [9] 2.01842371 -0.06271410
Next Steps
- Construct lots of use cases where pipes are used.
- Lots of unit tests based on these examples.
ramhiser commented
person = c( 'Grace', 'Grace', 'Grace', 'Rob', 'Rob', 'Rob' )
foods = c( 'apple', 'banana', 'cucumber', 'spaghetti', 'cucumber', 'banana' )
eaten <- data_frame(person, foods)
eaten %>% group_by(person) %>% do(function(x) combn(x$foods, m = 2))