R/col_back.R

Defines functions col_back

Documented in col_back

#' @title select columns to back
#' https://gist.githubusercontent.com/romainfrancois/5363c96646bb164f77fac2610d23b126/raw/0e4454a7c833d18998cac91df6403ad0f95d0eaf/frontback.md
#' @description select columns to back
#' @param df dataframe
#'
#' @return dataframe
#'
#' @examples
#' col_back(iris, Sepal.Length) %>% head()
#'
#' @import  purrr
#' @import  dplyr
#' @import  rlang
#'
#' @rdname col_back
#' @export
#'
#


col_back <- function(data, ...){
    dots <- quos(...)

    # negate each expression
    ndots <- map(dots, function(q) expr(-!!q) )

    # select the negated (rm the columns) and then select them back
    select( data, !!!ndots, !!!dots )
}
jixing475/manuscriptsJX documentation built on April 20, 2020, 9:55 a.m.