melt_list: melt_list

View source: R/melt_list.R

melt_listR Documentation

melt_list

Description

melt_list

Usage

melt_list(list, ..., na.rm = TRUE)

melt_tree(x, names, ...)

Arguments

list

A list object, with the same colnames data.frame in every element.

...

other parameters to melt

na.rm

Boolean

var.name

vector of id variables. Can be integer (variable position) or string (variable name). If blank, will use all non-measured variables.

References

  1. https://stackoverflow.com/questions/15673550/why-is-rbindlist-better-than-rbind

Examples

# data.frame
df <- data.frame(year = 2010, day = 1:3, month = 1, site = "A")
l <- list(a = df, b = df)

melt_list(l, 'id') %>% as_tibble()
melt_list(l, 'id' = 1) %>% as_tibble()
melt_list(set_names(l, NULL), 'id') %>% as_tibble()

# data.table
df <- data.table::data.table(year = 2010, day = 1:3, month = 1, site = "A")
l <- list(a = df, b = df)
melt_list(l, "id")
melt_list(l, id = c("a", "b"))
# int `id` is much more efficient
melt_list(l, id = c(1, 2))

kongdd/Ipaper documentation built on March 27, 2024, 5:34 a.m.