Picks the n species with the largest share (of the forested area, of the biomass, ...) from the shares of one landscape, e.g. today's landscape, so that reports can drop the rare ones.

top_species(shares, n)

Arguments

shares

named numeric vector: the share of each species, named by species code.

n

a single whole number, 0 or more; how many species to keep.

Value

A character vector of at most n species codes, the most abundant first.

Details

Species with a share of NA, NaN, 0 or below are not abundant and are never returned, so fewer than n names come back when fewer species occur. Species with equal shares are ordered by name, so the result does not depend on the order of shares. Names are compared in C-locale (byte) order, so every capitalised code sorts before every lower-case one ("Pice" before "abie"). The names must all be present, non-empty and unique; otherwise the function stops.