Skip to contents

Title

Usage

make_attribute(
  df,
  taxa_col = "original_name",
  att_col,
  taxonomy,
  max_guess = "family",
  agg_method = median,
  agg_round = 2,
  unknown_action = c("remove", "unknown"),
  context = NULL,
  remove_strings = c("n/a", "''", "NA"),
  ...
)

Arguments

df

Dataframe with taxa_col and att_col

taxa_col

Character name of column in df that was passed to get_taxonomy as taxa_col

att_col

Character name of column in df that contains the attribute to summarise

taxonomy

List resulting from call to make_taxonomy()

max_guess

Character. If attribute is not available for taxa, try guessing from values up to max_guess level of taxonomic hierarchy. See lurank. Note it does not make sense to provide a rank here that is lower than the target_rank provided to make_taxonomy when taxonomy was made.

agg_method

Function name to use for summarising numeric att_col. Ignored if att_col is not numeric

agg_round

Passed to base::round() round argument. Used if summarising numeric att_col.

unknown_action

When no other value can be found/guessed: either default 'remove' (no record returned); or provide a value to be used. Only used for character att_col

context

Any other columns in df to maintain throughout summarising.

remove_strings

Character. Any values in att_col to exclude

...

Passed to agg_method

Value

Dataframe with one row for each taxa and context with best guess at a single attribute based on the values in att_col