Skip to content

[Feature Request] Allow tabyl() to accept character vectors as column names #572

@EA-Ammar

Description

@EA-Ammar

Feature requests

It would be useful if tabyl() accepted a character vector of column names as the variables to be summarised, similar to many tidyselect() functions.

An example of how I imagine the code would work:

library("tidyverse")
library("janitor")

# Sample data
mydat <- tibble(x=c(1:4),y=c(5:8),z=c(11:14))

# Define vectors
vec1 <- c("x")
vec2 <- c("x","y")
vec3 <- c("x","y","z")

# All these lines produce the same output, equivalent to mydat %>% tabyl(x)
mydat %>% tabyl(all_of(vec1))
mydat %>% tabyl(all_of(vec2))
mydat %>% tabyl(all_of(vec3))

Currently tabyl only accepts the first element of the character vector as a parameter, so the tables are always one-way. Allowing the vector to be fed in with either 1, 2 or 3 arguments would allow a more flexible workflow, e.g. in custom functions integrating tabyl.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions