tbl_pivot_longer: Title

View source: R/basic_tbl_tools.R

tbl_pivot_longerR Documentation

Title

Description

Title

Usage

tbl_pivot_longer(
  data,
  long_columns = NULL,
  numeric_groups = NULL,
  names_to = "feature",
  values_to = "value",
  drop_na = T,
  names_prefix = NULL,
  names_pattern = NULL,
  ...
)

Arguments

...

Examples

library(tidyverse)
library(asbtools)
who %>% tbl_pivot_longer(
  cols = new_sp_m014:newrel_f65,
  names_to = c("diagnosis", "gender", "age"),
  names_pattern = "new_?(.*)_(.)(.*)",
  values_to = "count"
)

long_cols <- billboard %>% select(starts_with("wk")) %>% names()

billboard %>% tbl_pivot_longer(
  long_columns = long_cols,
  names_to = "week",
  names_prefix = "wk",
  values_to = "rank",
  values_drop_na = TRUE
)

relig_income %>%
  tbl_pivot_longer(names_to = "income", values_to = "count")

abresler/asbtools documentation built on July 28, 2022, 11:04 p.m.