dplyr Use Cases: Non-Interactive Mode

March 16, 2015

(This article was first published on Just Another Data Blog, and kindly contributed to R-bloggers)

The current release of dplyr (v 0.4.1) offers lot more flexibility regarding usage of important verbs in non-interactive mode. In this post, I’m exploring different possible use-cases.

  • group_by_, select_, rename_:

For group_by_, select_ and rename_, we can pass a character vector of variable names as an argument to .dots parameter.

  • filter_:

To use filter_ function, we need to pass filter criteria as a parameter to .dots. The criteria can be created using lazyeval::interp function.

  • mutate_, transmute_, summarise_:

We need to provide 2 things to these functions – a list of functions to be applied on the input variables (with corresponding input variables) and a character vector of output variables names. These 2 things can be passed to the .dots argument using combination of lazyeval::interp  and setNames function.

  • joins:
For 2 table verbs, there’s no *_join_ function and we don’t need one for general purposes. We can just pass a named vector to by argument. setNames function comes in handy while doing this.

The R Code for the above mentioned use cases is shown below and can also be found on this GitHub Gist.

To leave a comment for the author, please follow the link and comment on their blog: Just Another Data Blog.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)