list_df: Help export a single file by reducing a list of dataframes to...

Description Usage Arguments Value See Also Examples

Description

This function wraps purrr::reduce() and dplyr::full_join() to reduce all or some dataframes in a list into a single dataframe.

Usage

1
list_df(lst, df_names = NULL, by = NULL)

Arguments

lst

A list of dataframes.

df_names

Names of the list elements to join. NULL defaults to use all list elements.

by

A character vector of variables to join by. If NULL, the default, *_join() will do a natural join, using all variables with common names across the two tables. To join by different variables on x and y use a named vector. For example, by = c("a" = "b") will match x.a to y.b. Passed to dplyr::full_join()

Value

A dataframe.

See Also

purrr::reduce() and dplyr::full_join().

Other general functions to export data: list_csv

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
dfs <- list(
  a = data.frame(x = 1),
  b = data.frame(x = 2, y = 2),
  c = data.frame(x = 1, z = 3)
)

list_df(dfs)

list_df(dfs, df_names = c("a", "c"))

list_df(dfs, df_names = c("b", "c"))

# Use argument `by` if dataframes have no matching variable,
list_df(
  list(data.frame(x = 1), data.frame(z = 2)),
  by = c("x" = "z")
)

forestgeo/fgeo.misc documentation built on June 23, 2019, 6:26 p.m.