Description Usage Arguments Value Examples
User-friendly interface that synthesizes power of dplyr::left_join
and findInterval
.
1 | break_join(x, y, brk = character(), by = NULL, ...)
|
x |
A data frame. |
y |
Data frame containing desired reference information. |
brk |
Name of column in |
by |
Joining variables, if needed. See mutate-joins. |
... |
additional arguments automatically directed to |
An object of the same type as x
.
All x
rows will be returned.
All columns between x
and y
are returned.
Rows in y
are matched with x
based on overlapping values of brk
(e.g. findInterval(x$brk, y$brk, ...)
).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # joining USA + UK leaders with population time-series
break_join(us_uk_pop, us_uk_leaders, brk = c("date" = "start"))
# simple dataset
set.seed(1)
a <- data.frame(p = c(rep("A", 10), rep("B", 10)), q = runif(20, 0, 10))
b <- data.frame(p = c("A", "A", "B", "B"), q = c(3, 5, 6, 9), r = c("a1", "a2", "b1", "b2"))
break_join(a, b, brk = "q") # p identified as common variable automatically
break_join(a, b, brk = "q", by = "p") # same result
break_join(a, b, brk = "q", all.inside = TRUE) # note missing values have been filled
# joining toll prices with vehicle time-series
library(mopac)
library(dplyr, warn.conflicts = FALSE)
library(hms)
express %>%
mutate(time_hms = as_hms(time)) %>%
break_join(rates, brk = c("time_hms" = "time"))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.