Combine datasets using dplyr's bind and join functions

combine_data(
  x,
  y,
  by = "",
  add = "",
  type = "inner_join",
  data_filter = "",
  envir = parent.frame(),
  ...
)

Arguments

x

Dataset

y

Dataset to combine with x

by

Variables used to combine `x` and `y`

add

Variables to add from `y`

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 https://radiant-rstats.github.io/docs/data/combine.html for further details

data_filter

Expression used to filter the dataset. This should be a string (e.g., "price > 10000")

envir

Environment to extract data from

...

further arguments passed to or from other methods

Value

Combined dataset

Details

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

Examples

avengers %>% combine_data(superheroes, type = "bind_cols")
#> New names: #> * name -> name...1 #> * alignment -> alignment...2 #> * gender -> gender...3 #> * publisher -> publisher...4 #> * name -> name...5 #> * ...
#> # A tibble: 7 x 8 #> name...1 alignment...2 gender...3 publisher...4 name...5 alignment...6 #> <chr> <chr> <chr> <chr> <chr> <chr> #> 1 Thor good male Marvel Magneto bad #> 2 Iron Man good male Marvel Storm good #> 3 Hulk good male Marvel Mystique bad #> 4 Hawkeye good male Marvel Batman good #> 5 Black W… good female Marvel Joker bad #> 6 Captain… good male Marvel Catwoman bad #> 7 Magneto bad male Marvel Hellboy good #> # … with 2 more variables: gender...7 <chr>, publisher...8 <chr>
combine_data(avengers, superheroes, type = "bind_cols")
#> New names: #> * name -> name...1 #> * alignment -> alignment...2 #> * gender -> gender...3 #> * publisher -> publisher...4 #> * name -> name...5 #> * ...
#> # A tibble: 7 x 8 #> name...1 alignment...2 gender...3 publisher...4 name...5 alignment...6 #> <chr> <chr> <chr> <chr> <chr> <chr> #> 1 Thor good male Marvel Magneto bad #> 2 Iron Man good male Marvel Storm good #> 3 Hulk good male Marvel Mystique bad #> 4 Hawkeye good male Marvel Batman good #> 5 Black W… good female Marvel Joker bad #> 6 Captain… good male Marvel Catwoman bad #> 7 Magneto bad male Marvel Hellboy good #> # … with 2 more variables: gender...7 <chr>, publisher...8 <chr>
avengers %>% combine_data(superheroes, type = "bind_rows")
#> # A tibble: 14 x 4 #> name alignment gender publisher #> <chr> <chr> <chr> <chr> #> 1 Thor good male Marvel #> 2 Iron Man good male Marvel #> 3 Hulk good male Marvel #> 4 Hawkeye good male Marvel #> 5 Black Widow good female Marvel #> 6 Captain America good male Marvel #> 7 Magneto bad male Marvel #> 8 Magneto bad male Marvel #> 9 Storm good female Marvel #> 10 Mystique bad female Marvel #> 11 Batman good male DC #> 12 Joker bad male DC #> 13 Catwoman bad female DC #> 14 Hellboy good male Dark Horse Comics
avengers %>% combine_data(superheroes, add = "publisher", type = "bind_rows")
#> # A tibble: 14 x 4 #> name alignment gender publisher #> <chr> <chr> <chr> <chr> #> 1 Thor good male Marvel #> 2 Iron Man good male Marvel #> 3 Hulk good male Marvel #> 4 Hawkeye good male Marvel #> 5 Black Widow good female Marvel #> 6 Captain America good male Marvel #> 7 Magneto bad male Marvel #> 8 Magneto bad male Marvel #> 9 Storm good female Marvel #> 10 Mystique bad female Marvel #> 11 Batman good male DC #> 12 Joker bad male DC #> 13 Catwoman bad female DC #> 14 Hellboy good male Dark Horse Comics