Based on a reference dataset x, this function helps you identify stems that remain to be recensused in a dataset y. This function does the same work as dplyr::anti_join(). The only difference is that the signature of pick_recensus() is a little simpler (irrelevant arguments hidden via ...) to focus your attention on the arguments that are most useful in helping you identify stems to recensus. This function also exists to help you discover the *join() functions of dplyr, which will help you solve more general problems.

pick_recensus(x, y, by = NULL, ...)

Arguments

x, y

Dataframes to join:

  • x: Reference table with columns giving information on the unique identifier of each stem and the quadrat it occurs.

  • y: Table with column giving information on the unique identifier of each stem.

by

a character vector of variables to join by. If NULL, the default, *_join() will do a natural join, using all variables with common names across the two tables. A message lists the variables so that you can check they're right (to suppress the message, simply explicitly list the variables that you want to join).

To join by different variables on x and y use a named vector. For example, by = c("a" = "b") will match x.a to y.b.

...

Other parameters passed onto dplyr::anti_join.

Value

Returns all rows from x where there are not matching values in y, keeping just columns from x.

Details

This function preserves dplyr's style and thus non-standard evaluation. If you want to use it inside your own functions, you should learn about tidy eval (implemented via the rlang package). A good place to start is at dplyr's website.

See also

Other general functions to pick or drop rows of a dataframe: in_top, pick_top

Examples

x <- tibble::tribble( ~unique_stem, ~quadrat, "01_1", "001", "02_1", "001", "02_2", "001", "04_1", "002", "04_2", "002", "05_1", "002" ) y <- tibble::tribble( ~unique_stem, "01_1", "02_2", "04_2" ) pick_recensus(x, y)
#> Joining, by = "unique_stem"
#> # A tibble: 3 x 2 #> unique_stem quadrat #> <chr> <chr> #> 1 02_1 001 #> 2 04_1 002 #> 3 05_1 002
# Same pick_recensus(x, y, by = "unique_stem")
#> # A tibble: 3 x 2 #> unique_stem quadrat #> <chr> <chr> #> 1 02_1 001 #> 2 04_1 002 #> 3 05_1 002
y2 <- dplyr::tribble( ~unq_stem, "01_1", "02_2", "04_2" ) pick_recensus(x, y2, by = c("unique_stem" = "unq_stem"))
#> # A tibble: 3 x 2 #> unique_stem quadrat #> <chr> <chr> #> 1 02_1 001 #> 2 04_1 002 #> 3 05_1 002
# For this and more general problems you can use `dplyr::*_join()` functions dplyr::anti_join(x, y2, by = c("unique_stem" = "unq_stem"))
#> # A tibble: 3 x 2 #> unique_stem quadrat #> <chr> <chr> #> 1 02_1 001 #> 2 04_1 002 #> 3 05_1 002