Count observations for each taxon in a data set in a taxmap() object. This includes observations for the specific taxon and the observations of its subtaxa. "Observations" in this sense are the items (for list/vectors) or rows (for tables) in a dataset. By default, observations in the first data set in the taxmap() object is used. For example, if the data set is a table, then a value of 3 for a taxon means that their are 3 rows in that table assigned to that taxon or one of its subtaxa.

obj$n_obs(data)
n_obs(obj, data)

Arguments

obj

(taxmap())

data

Dataset name, index, or a logical vector that indicates which dataset in obj$data to add columns to.

target

DEPRECIATED. use "data" instead.

Value

numeric

See also

Other taxmap data functions: n_obs_1()

Examples

# Get number of observations for each taxon in first dataset n_obs(ex_taxmap)
#> b c d e f g h i j k l m n o p q r #> 4 2 2 1 1 2 1 1 1 1 2 1 1 1 1 1 1
# Get number of observations in a specified data set n_obs(ex_taxmap, "info")
#> b c d e f g h i j k l m n o p q r #> 4 2 2 1 1 2 1 1 1 1 2 1 1 1 1 1 1
n_obs(ex_taxmap, "abund")
#> b c d e f g h i j k l m n o p q r #> 8 0 4 2 2 0 2 2 2 2 0 2 2 2 2 0 0
# Filter taxa using number of observations in the first table filter_taxa(ex_taxmap, n_obs > 1)
#> <Taxmap> #> 5 taxa: b. Mammalia, c. Plantae, d. Felidae, g. Solanaceae, l. Solanum #> 5 edges: NA->b, NA->c, b->d, c->g, g->l #> 4 data sets: #> info: #> # A tibble: 6 x 4 #> taxon_id name n_legs dangerous #> <chr> <chr> <dbl> <lgl> #> 1 d tiger 4 TRUE #> 2 d cat 4 FALSE #> 3 b mole 4 FALSE #> # … with 3 more rows #> phylopic_ids: a named vector of 'character' with 6 items #> d. e148eabb-f138-43[truncated] ... l. 63604565-0406-46[truncated] #> foods: a list of 6 items named by taxa: #> d, d, b, b, l, l #> abund: #> # A tibble: 8 x 5 #> taxon_id code sample_id count taxon_index #> <chr> <fct> <fct> <dbl> <int> #> 1 d T A 1 1 #> 2 d C A 2 2 #> 3 b M B 5 3 #> # … with 5 more rows #> 1 functions: #> reaction