#' Enhanced gather supporting keep argument
#'
#' @inheritParams tidyr::gather
#' @param keep columns to keep, additionally to columns mentionned in \code{...}.
#' Passed to \code{select} so supports select helper, including tidyx helper
#' \code{nothing()}.
#'
#' @export
gatherx <- function(data, key = "key", value = "value", ..., na.rm = FALSE,
convert = FALSE, factor_key = FALSE, keep = dplyr::everything()){
key <- rlang::enquo(key)
value <- rlang::enquo(value)
keep <- rlang::enquo(keep)
data <- data %>% dplyr::select(..., !!keep)
tidyr::gather(data, !!key, !!value, ...,
na.rm = na.rm, convert = convert, factor_key = factor_key)
}
#' Select helper to select nothing
#'
#' @export
nothing <- function(){
integer(0)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.