longen: Create long format of a dataframe, keeping the id column.

View source: R/utils.R

longenR Documentation

Create long format of a dataframe, keeping the id column.

Description

Create long format of a dataframe, keeping the id column.

Usage

longen(df, id = "id")

Arguments

df

Dataframe with a key variable (id).

id

name of the key variable in the dataframe.

Value

Dataframe consisting of 3 columns id, var & val, containing the dataframe in long format (based on dplyr::gather).

Examples

# load spss data
path <- system.file("examples", "iris.sav", package = "haven")
df <- haven::read_sav(path) %>%
  # add id column
  tibble::rownames_to_column("id")
df %>% longen()

urswilke/tablab documentation built on Oct. 17, 2022, 8:19 p.m.