diff --git a/R/generics_and_methods.R b/R/generics_and_methods.R index bd46cab..657eaae 100644 --- a/R/generics_and_methods.R +++ b/R/generics_and_methods.R @@ -28,15 +28,15 @@ #' @export #' @examples #' # See README for a more verbose version -#' -#' male_penguins <- tibble::tribble( +#' library(tibble) +#' male_penguins <- tribble( #' ~name, ~species, ~island, ~flipper_length_mm, ~body_mass_g, #' "Giordan", "Gentoo", "Biscoe", 222L, 5250L, #' "Lynden", "Adelie", "Torgersen", 190L, 3900L, #' "Reiner", "Adelie", "Dream", 185L, 3650L #' ) #' -#' female_penguins <- tibble::tribble( +#' female_penguins <- tribble( #' ~name, ~species, ~island, ~flipper_length_mm, ~body_mass_g, #' "Alonda", "Gentoo", "Biscoe", 211, 4500L, #' "Ola", "Adelie", "Dream", 190, 3600L, @@ -50,8 +50,8 @@ #' check = check_specs(implicit_keys = "ignore", duplicate_keys_right = "inform") #' ) #' -#' df1 <- tibble::tibble(id = 1:3, value = c(10, NA, 30)) -#' df2 <- tibble::tibble(id = 2:4, value = c(22, 32, 42)) +#' df1 <- tibble(id = 1:3, value = c(10, NA, 30)) +#' df2 <- tibble(id = 2:4, value = c(22, 32, 42)) #' #' # handle conflicted columns when joining #' power_left_join(df1, df2, by = "id", conflict = `+`) @@ -122,15 +122,15 @@ #' ) #' #' # fill unmatched values -#' df1 <- tibble::tibble(id = 1:3) -#' df2 <- tibble::tibble(id = 1:2, value2 = c(2, NA), value3 = c(NA, 3)) +#' df1 <- tibble(id = 1:3) +#' df2 <- tibble(id = 1:2, value2 = c(2, NA), value3 = c(NA, 3)) #' power_left_join(df1, df2, by = "id", fill = 0) #' power_left_join(df1, df2, by = "id", fill = list(value2 = 0)) #' #' # join recursively -#' df1 <- tibble::tibble(id = 1, a = "foo") -#' df2 <- tibble::tibble(id = 1, b = "bar") -#' df3 <- tibble::tibble(id = 1, c = "baz") +#' df1 <- tibble(id = 1, a = "foo") +#' df2 <- tibble(id = 1, b = "bar") +#' df3 <- tibble(id = 1, c = "baz") #' power_left_join(list(df1, df2, df3), by = "id") #' power_left_join(df1, list(df2, df3), by = "id") #' diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 6359912..18c9be4 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -2,5 +2,5 @@ pandoc: 2.14.0.3 pkgdown: 2.0.1 pkgdown_sha: ~ articles: {} -last_built: 2022-01-12T22:43Z +last_built: 2022-01-13T00:26Z diff --git a/docs/reference/power_left_join.html b/docs/reference/power_left_join.html index c86b99e..f554508 100644 --- a/docs/reference/power_left_join.html +++ b/docs/reference/power_left_join.html @@ -157,15 +157,15 @@
# See README for a more verbose version
-
-male_penguins <- tibble::tribble(
+library(tibble)
+male_penguins <- tribble(
~name, ~species, ~island, ~flipper_length_mm, ~body_mass_g,
"Giordan", "Gentoo", "Biscoe", 222L, 5250L,
"Lynden", "Adelie", "Torgersen", 190L, 3900L,
"Reiner", "Adelie", "Dream", 185L, 3650L
)
-female_penguins <- tibble::tribble(
+female_penguins <- tribble(
~name, ~species, ~island, ~flipper_length_mm, ~body_mass_g,
"Alonda", "Gentoo", "Biscoe", 211, 4500L,
"Ola", "Adelie", "Dream", 190, 3600L,
@@ -190,8 +190,8 @@ Examples#> 2 Gentoo Biscoe
#> 3 Adelie Dream
-df1 <- tibble::tibble(id = 1:3, value = c(10, NA, 30))
-df2 <- tibble::tibble(id = 2:4, value = c(22, 32, 42))
+df1 <- tibble(id = 1:3, value = c(10, NA, 30))
+df2 <- tibble(id = 2:4, value = c(22, 32, 42))
# handle conflicted columns when joining
power_left_join(df1, df2, by = "id", conflict = `+`)
@@ -242,7 +242,12 @@ Examples female_penguins %>% select_keys_and(female_name = name),
by = c("species", "island")
)
-#> Error in male_penguins %>% select_keys_and(name): could not find function "%>%"
+#> # A tibble: 3 × 4
+#> species island name female_name
+#> <chr> <chr> <chr> <chr>
+#> 1 Gentoo Biscoe Giordan Alonda
+#> 2 Gentoo Biscoe Giordan Mishayla
+#> 3 Adelie Dream Reiner Ola
# semi join
power_inner_join(
@@ -250,7 +255,12 @@ Examples female_penguins %>% select_keys_and(),
by = c("species", "island")
)
-#> Error in female_penguins %>% select_keys_and(): could not find function "%>%"
+#> # A tibble: 3 × 5
+#> name species island flipper_length_mm body_mass_g
+#> <chr> <chr> <chr> <int> <int>
+#> 1 Giordan Gentoo Biscoe 222 5250
+#> 2 Giordan Gentoo Biscoe 222 5250
+#> 3 Reiner Adelie Dream 185 3650
# agregate without repeating keys
power_left_join(
@@ -258,7 +268,12 @@ Examples female_penguins %>% summarize_by_keys(female_weight = mean(body_mass_g)),
by = c("species", "island")
)
-#> Error in male_penguins %>% summarize_by_keys(male_weight = mean(body_mass_g)): could not find function "%>%"
+#> # A tibble: 3 × 4
+#> species island male_weight female_weight
+#> <chr> <chr> <dbl> <dbl>
+#> 1 Adelie Dream 3650 3600
+#> 2 Adelie Torgersen 3900 NA
+#> 3 Gentoo Biscoe 5250 4625
# pack auxiliary colums without repeating keys
power_left_join(
@@ -266,7 +281,13 @@ Examples female_penguins %>% pack_along_keys(name = "f"),
by = c("species", "island")
)
-#> Error in male_penguins %>% pack_along_keys(name = "m"): could not find function "%>%"
+#> # A tibble: 4 × 4
+#> species island m$name $flipper_length… $body_mass_g f$name $flipper_length…
+#> <chr> <chr> <chr> <int> <int> <chr> <dbl>
+#> 1 Gentoo Biscoe Giord… 222 5250 Alonda 211
+#> 2 Gentoo Biscoe Giord… 222 5250 Misha… 215
+#> 3 Adelie Torgersen Lynden 190 3900 NA NA
+#> 4 Adelie Dream Reiner 185 3650 Ola 190
# fuzzy join
power_inner_join(
@@ -274,7 +295,11 @@ Examples female_penguins %>% select_keys_and(female_name = name),
by = c(~.x$flipper_length_mm < .y$flipper_length_mm, ~.x$body_mass_g > .y$body_mass_g)
)
-#> Error in male_penguins %>% select_keys_and(male_name = name): could not find function "%>%"
+#> # A tibble: 1 × 6
+#> flipper_length_mm.x body_mass_g.x male_name flipper_length_mm.y body_mass_g.y
+#> <int> <int> <chr> <dbl> <int>
+#> 1 185 3650 Reiner 190 3600
+#> # … with 1 more variable: female_name <chr>
# fuzzy + equi join
power_inner_join(
@@ -282,7 +307,11 @@ Examples female_penguins %>% select_keys_and(female_name = name),
by = c("island", ~.x$flipper_length_mm > .y$flipper_length_mm)
)
-#> Error in male_penguins %>% select_keys_and(male_name = name): could not find function "%>%"
+#> # A tibble: 2 × 5
+#> island flipper_length_mm.x male_name flipper_length_mm.y female_name
+#> <chr> <int> <chr> <dbl> <chr>
+#> 1 Biscoe 222 Giordan 211 Alonda
+#> 2 Biscoe 222 Giordan 215 Mishayla
# define new column without repeating computation
power_inner_join(
@@ -290,18 +319,28 @@ Examples female_penguins %>% select_keys_and(female_name = name),
by = ~ (mass_ratio <- .y$body_mass_g / .x$body_mass_g) > 1.2
)
-#> Error in male_penguins %>% select_keys_and(male_name = name): could not find function "%>%"
+#> # A tibble: 3 × 5
+#> body_mass_g.x male_name body_mass_g.y female_name mass_ratio
+#> <int> <chr> <int> <chr> <dbl>
+#> 1 3900 Lynden 4750 Mishayla 1.22
+#> 2 3650 Reiner 4500 Alonda 1.23
+#> 3 3650 Reiner 4750 Mishayla 1.30
power_inner_join(
male_penguins %>% select_keys_and(male_name = name),
female_penguins %>% select_keys_and(female_name = name),
by = ~ (mass_ratio <- .y$body_mass_g / .x$body_mass_g) > 1.2,
keep = "none"
)
-#> Error in male_penguins %>% select_keys_and(male_name = name): could not find function "%>%"
+#> # A tibble: 3 × 3
+#> male_name female_name mass_ratio
+#> <chr> <chr> <dbl>
+#> 1 Lynden Mishayla 1.22
+#> 2 Reiner Alonda 1.23
+#> 3 Reiner Mishayla 1.30
# fill unmatched values
-df1 <- tibble::tibble(id = 1:3)
-df2 <- tibble::tibble(id = 1:2, value2 = c(2, NA), value3 = c(NA, 3))
+df1 <- tibble(id = 1:3)
+df2 <- tibble(id = 1:2, value2 = c(2, NA), value3 = c(NA, 3))
power_left_join(df1, df2, by = "id", fill = 0)
#> # A tibble: 3 × 3
#> id value2 value3
@@ -318,9 +357,9 @@ Examples#> 3 3 0 NA
# join recursively
-df1 <- tibble::tibble(id = 1, a = "foo")
-df2 <- tibble::tibble(id = 1, b = "bar")
-df3 <- tibble::tibble(id = 1, c = "baz")
+df1 <- tibble(id = 1, a = "foo")
+df2 <- tibble(id = 1, b = "bar")
+df3 <- tibble(id = 1, c = "baz")
power_left_join(list(df1, df2, df3), by = "id")
#> # A tibble: 1 × 4
#> id a b c
diff --git a/docs/reference/preprocess_inputs.html b/docs/reference/preprocess_inputs.html
index deb9637..4141602 100644
--- a/docs/reference/preprocess_inputs.html
+++ b/docs/reference/preprocess_inputs.html
@@ -106,7 +106,7 @@ Examples#> [[1]]
#> <quosure>
#> expr: ^Sepal.Width
-#> env: 0x1120a4208
+#> env: 0x113548a10
#>
#>
# see `?power_left_join` or README for practical examples
diff --git a/man/power_left_join.Rd b/man/power_left_join.Rd
index 9684b84..2733b8a 100644
--- a/man/power_left_join.Rd
+++ b/man/power_left_join.Rd
@@ -118,15 +118,15 @@ Power joins
}
\examples{
# See README for a more verbose version
-
-male_penguins <- tibble::tribble(
+library(tibble)
+male_penguins <- tribble(
~name, ~species, ~island, ~flipper_length_mm, ~body_mass_g,
"Giordan", "Gentoo", "Biscoe", 222L, 5250L,
"Lynden", "Adelie", "Torgersen", 190L, 3900L,
"Reiner", "Adelie", "Dream", 185L, 3650L
)
-female_penguins <- tibble::tribble(
+female_penguins <- tribble(
~name, ~species, ~island, ~flipper_length_mm, ~body_mass_g,
"Alonda", "Gentoo", "Biscoe", 211, 4500L,
"Ola", "Adelie", "Dream", 190, 3600L,
@@ -140,8 +140,8 @@ power_inner_join(
check = check_specs(implicit_keys = "ignore", duplicate_keys_right = "inform")
)
-df1 <- tibble::tibble(id = 1:3, value = c(10, NA, 30))
-df2 <- tibble::tibble(id = 2:4, value = c(22, 32, 42))
+df1 <- tibble(id = 1:3, value = c(10, NA, 30))
+df2 <- tibble(id = 2:4, value = c(22, 32, 42))
# handle conflicted columns when joining
power_left_join(df1, df2, by = "id", conflict = `+`)
@@ -212,15 +212,15 @@ power_inner_join(
)
# fill unmatched values
-df1 <- tibble::tibble(id = 1:3)
-df2 <- tibble::tibble(id = 1:2, value2 = c(2, NA), value3 = c(NA, 3))
+df1 <- tibble(id = 1:3)
+df2 <- tibble(id = 1:2, value2 = c(2, NA), value3 = c(NA, 3))
power_left_join(df1, df2, by = "id", fill = 0)
power_left_join(df1, df2, by = "id", fill = list(value2 = 0))
# join recursively
-df1 <- tibble::tibble(id = 1, a = "foo")
-df2 <- tibble::tibble(id = 1, b = "bar")
-df3 <- tibble::tibble(id = 1, c = "baz")
+df1 <- tibble(id = 1, a = "foo")
+df2 <- tibble(id = 1, b = "bar")
+df3 <- tibble(id = 1, c = "baz")
power_left_join(list(df1, df2, df3), by = "id")
power_left_join(df1, list(df2, df3), by = "id")