Learn R Programming

radiant.data (version 0.6.0)

combinedata: Combine datasets using dplyr's bind and join functions

Description

Combine datasets using dplyr's bind and join functions

Usage

combinedata(dataset, cmb_dataset, by = "", add = "", type = "inner_join", name = "", data_filter = "")

Arguments

dataset
Dataset name (string). This can be a dataframe in the global environment or an element in an r_data list from Radiant
cmb_dataset
Dataset name (string) to combine with `dataset`. This can be a dataframe in the global environment or an element in an r_data list from Radiant
by
Variables used to combine `dataset` and `cmb_dataset`
add
Variables to add from `cmb_dataset`
type
The main bind and join types from the dplyr package are provided. inner_join returns all rows from x with matching values in y, and all columns from x and y. If there are multiple matches between x and y, all match combinations are returned. left_join returns all rows from x, and all columns from x and y. If there are multiple matches between x and y, all match combinations are returned. right_join is equivalent to a left join for datasets y and x. full_join combines two datasets, keeping rows and columns that appear in either. semi_join returns all rows from x with matching values in y, keeping just columns from x. A semi join differs from an inner join because an inner join will return one row of x for each matching row of y, whereas a semi join will never duplicate rows of x. anti_join returns all rows from x without matching values in y, keeping only columns from x. bind_rows and bind_cols are also included, as are intersect, union, and setdiff. See http://radiant-rstats.github.io/docs/data/combine.html for further details
name
Name for the combined dataset
data_filter
Expression used to filter the dataset. This should be a string (e.g., "price > 10000")

Value

If list `r_data` exists the combined dataset is added as `name`. Else the combined dataset will be returned as `name`

Details

See http://radiant-rstats.github.io/docs/data/combine.html for an example in Radiant

Examples

Run this code
avengers %>% combinedata(superheroes, type = "bind_cols")
combinedata("avengers", "superheroes", type = "bind_cols")
avengers %>% combinedata(superheroes, type = "bind_rows")
avengers %>% combinedata(superheroes, add = "publisher", type = "bind_rows")

Run the code above in your browser using DataLab