extended-equality | R Documentation |
%==%
is the bone operator, it works like ==
but NA %==% 1
is FALSE
and
NA %==% NA
is TRUE
. %in.%
is the a vectorized %in%
, that
can be seen as a rowwise %in%
when applied to data frame columns. These are
convenient helpers for fuzzy joins.
x %==% y
x %in.% y
x |
A vector |
y |
A vector for |
df1 <- data.frame(key = c("b", "z"))
df2 <- data.frame(key1 = c("a", "b", "c"), key2 = c("x", "y", "z"), val = 1:3)
power_left_join(df1, df2, ~ .x$key %in.% list(.y$key1, .y$key2))
df3 <- data.frame(key1 = c("a", NA))
df4 <- data.frame(key2 = c("a", "b", NA), val = 1:3)
# note the difference
power_inner_join(df3, df4, by = ~ .x$key1 == .y$key2)
power_inner_join(df3, df4, by = ~ .x$key1 %==% .y$key2)
# typically we would only use the conditions above as part of more complex conditions.
# In this precise case they are equivalent to these equi joins
power_inner_join(df3, df4, by = c(key1 = "key2"))
power_inner_join(df3, df4, by = c(key1 = "key2"), na_matches = "never")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.