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

let crosstab be called in a pipeline #33

Closed
2 tasks done
sfirke opened this issue Jul 6, 2016 · 5 comments
Closed
2 tasks done

let crosstab be called in a pipeline #33

sfirke opened this issue Jul 6, 2016 · 5 comments

Comments

@sfirke
Copy link
Owner

sfirke commented Jul 6, 2016

  • Update crosstab() code
  • Update vignette

Idea from @chrishaid

by creating another function. Here is a crude mockup:

crosstab_df <- function(dat, ...){
  names <- as.list(substitute(list(...)))[-1L]
  names <- unlist(lapply(names, deparse))
  trimmed <- dat %>% select_(.dots = names)
  crosstab(trimmed[[1]], trimmed[[2]])
}

Which works: mtcars %>% crosstab_df(cyl, am) (sort of, variable name is lost in the result)

Do this for tabyl() too as tabyl_df(), right now it's tedious to have a dplyr pipeline with a filter, etc. that I have to interrupt to use tabyl() (or use use_series() which isn't even an option for crosstab()).

@chrishaid
Copy link
Collaborator

I'm working on this now, which means I'm muddeling through a lot of NSE problems.

@sfirke
Copy link
Owner Author

sfirke commented Jul 7, 2016

Awesome! And not awesome, respectively. I have had a lot of trouble with NSE while writing this package 👎

When I got your email about using S3 to have a method work on different classes, I thought "I'm going to learn something here." I googled it, and I think I get what you're going for, which would be brilliant.

@chrishaid
Copy link
Collaborator

I've got it mostly working. Can you make me a contributor on this repo so I can push a branch?

@chrishaid
Copy link
Collaborator

chrishaid commented Jul 7, 2016

Actually, ignore that last request. I've just forked and recloned the repo.

@sfirke
Copy link
Owner Author

sfirke commented Jul 8, 2016

Very nice work. I am leaving this open just until I update the vignette accordingly. And I'll try to adapt the approach you've taken here to the tabyl() function which I also often call from a pipeline.

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

2 participants