tidyr::gather - operating on ellipsis

Images
Related searches

The code below is my original intent.

gather_df <- function (...) {
  mtcars %>% 
    group_by(...) %>% 
    tidyr::gather(key, value, -vs)
}

gather_df(vs)

To further generalize, is it possible to operate on the ellipsis?

gather_df <- function (...) {
  mtcars %>% 
    group_by(...) %>% 
    tidyr::gather(key, value, -...)
}

gather_df(vs)

We can use enquos to capture all inputs then evaluate them using !!!

library(dplyr)
gather_df <- function (...) {
  vars<-enquos(...)
  mtcars %>% 
    group_by(!!!vars) %>% 
    tidyr::gather(key, value, -c(!!!vars))
}

gather_df(vs)
gather_df(vs,cyl)
gather_df(vs,cyl,hp)

PS: I'm using rlang 0.3.1

Gather columns into key-value pairs — gather • tidyr, For more options, see the dplyr::select() documentation. See also the section on selection rules below. na.rm. If TRUE , will remove rows from output where the� Introduction to R. The gather() Function. The second tidyr function we will look into is the gather() function. With gather() it may not be clear what exactly is going on, but in this case we actually have a lot of column names the represent what we would like to have as data values.

Alternative argument as character (rlang > 0.1.2).

gather_df <- function (...) {
  grp_var <- rlang::sym(...)
  mtcars %>% 
    group_by(!!!grp_var) %>% 
    gather(key, value, -!!(grp_var))
}

gather_df("vs")

Changelog • tidyr, These functions resolve multiple existing issues with spread() / gather() . instrumented with functions from the ellipsis package to warn if you've supplied arguments that are uncount() performs the inverse operation of dplyr::count() (# 279)� Gather takes multiple columns and collapses into key-value pairs, duplicating all other columns as needed. You use gather() when you notice that you have columns that are not variables.</p>

I used quo() instead of enquos() to maintain rlang 0.1.2 compatibility.

gather_df <- function (...) {
  vars <- quo(...)
  mtcars %>% 
    group_by(!!!vars) %>% 
    tidyr::gather(key, value, -c(!!!vars))
}

gather_df(vs)

[PDF] tidyr, ellipsis (>= 0.1.0), glue, dplyr::left_join() and replace_na() that's useful for completing missing combinations of gather. Arguments data. A data frame. key, value. Names of new key and value columns, Nesting is implicitly a summarising operation: you get one row for each group defined by the non-. Overview of tidyr tidyr is a wonderful package in R written by Hadley Wickham for the purpose of helping you to apply the principles of tidy data. How to install tidyr Since tidyr is a part of tidyverse group of packages, it can be installed either by installing tidyverse or just tidyr itself #Installing tidyr

tidyr::gather() throws Error: 'check_dots_unnamed' is not an , tidyr::gather() throws Error: 'check_dots_unnamed' is not an exported object from ' namespace:ellipsis' #611. Closed. sfirke opened this issue� data: A data frame. key, value: Names of new key and value columns, as strings or symbols. This argument is passed by expression and supports quasiquotation (you can unquote strings and symbols).

gather function, Gather takes multiple columns and collapses into key-value pairs, duplicating all other columns as For more options, see the dplyr::select() documentation. Find out how to use and troubleshoot your Verizon Ellipsis 10 with interactive simulators, how-to guides and support videos.

This equipment generates, uses, The antenna(s) used for this transmitter must not be co- and can radiate radio frequency energy, and, if not installed located or operating in conjunction with any other antenna or and used in accordance with the instructions, may cause transmitter. harmful interference to radio communications.

Comments
  • Thanks. It runs on rlang 0.3.0.1 but it didn't quite work on 0.1.2.