pick_recensus: Pick rows from table x with no-match in table y (e.g. find...

Description Usage Arguments Details Value See Also Examples

Description

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.

Usage

1

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.

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.

Value

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

See Also

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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)

# Same
pick_recensus(x, y, by = "unique_stem")

y2 <- dplyr::tribble(
  ~unq_stem,
     "01_1",
     "02_2",
     "04_2"
)
pick_recensus(x, y2, by = c("unique_stem" = "unq_stem"))

# For this and more general problems you can use `dplyr::*_join()` functions
dplyr::anti_join(x, y2, by = c("unique_stem" = "unq_stem"))

forestgeo/fgeo.misc documentation built on June 23, 2019, 6:26 p.m.