Filter observations with a list of conditions

Filter data in a taxmap() object (in obj$data) with a set of conditions. See dplyr::filter() for the inspiration for this function and more information. Calling the function using the obj$filter_obs(...) style edits "obj" in place, unlike most R functions. However, calling the function using the filter_obs(obj, ...) imitates R's traditional copy-on-modify semantics, so "obj" would not be changed; instead a changed version would be returned, like most R functions.

obj$filter_obs(target, ..., drop_taxa = FALSE)
filter_obs(obj, target, ..., drop_taxa = FALSE)


An object of type taxmap()


The name of the list/vector/table in obj$data to filter


One or more filtering conditions. Any variable name that appears in all_names() can be used as if it was a vector on its own. Each filtering condition can be one of three things:

  • integer: One or more row indexes of obj[target]

  • logical: A TRUE/FALSE vector of length equal to the number of rows in obj[target]


(logical of length 1) If FALSE, preserve taxa even if all of their observations are filtered out. If TRUE, remove taxa for which all observations were filtered out. Note that only taxa that are unobserved due to this filtering will be removed; there might be other taxa without observations to begin with that will not be removed.


An object of type taxmap()

See Also

Other taxmap manipulation functions: arrange_obs, arrange_taxa, filter_taxa, mutate_obs, sample_frac_obs, sample_frac_taxa, sample_n_obs, sample_n_taxa, select_obs, transmute_obs

  • filter_obs
# Filter by row index
filter_obs(ex_taxmap, "info", 1:2)

# Filter by TRUE/FALSE
filter_obs(ex_taxmap, "info", dangerous == FALSE)

# Remove taxa whose obserservation were filtered out
filter_obs(ex_taxmap, "info", dangerous == FALSE, drop_taxa = TRUE)

# }
Documentation reproduced from package taxa, version 0.1.0, License: MIT + file LICENSE

Community examples

Looks like there are no examples yet.