Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate with magrittr #43

Open
ramhiser opened this issue Aug 10, 2015 · 1 comment
Open

Integrate with magrittr #43

ramhiser opened this issue Aug 10, 2015 · 1 comment

Comments

@ramhiser
Copy link
Owner

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
Copy link
Owner Author

ramhiser commented Feb 6, 2017

A good motivating example:

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))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant