pct_cover: Percent cover

View source: R/pct_cover.R

pct_coverR Documentation

Percent cover

Description

Calculate the percent cover by plot for variables or combinations of variables. Percent cover will be calculated for every combination of the variables requested, so if the variables are GrowthHabitSub and Duration then the output will contain fields like Graminoid.Perennial, Graminoid.Annual, Shrub.Perennial, etc. whereas using just the variable code will produce one column per species code. Any number of indicator variables can be used. These are calculated as cover from anywhere in the canopy column or as only the first hit in the canopy column. Any groupings where all the variable values were NA will be dropped.

Usage

pct_cover(lpi_tall, tall = FALSE, hit = "any", by_line = FALSE, ...)

Arguments

lpi_tall

A tall/long-format data frame. Use the data frame "layers" from the gather.lpi() output.

tall

Logical. If TRUE then the returned data frame will be tall rather than wide and will not have observations for non-existent values e.g., if no data fell into a group on a plot, there will be no row for that group on that plot. Defaults to FALSE.

hit

Character string. If "any" then percent cover will be calculated using any hit in the canopy column (so a single pin drop record may be counted more than once if it had hits that corresponded to different groups). If "first" then only the first canopy hit at a pin drop will be used to calculate cover. If "basal", then only the soil surfacy hit will be used to calculate cover. Defaults to "any".

by_line

Logical. If TRUE then results will be reported further grouped by line using the LineID and LineKey fields from the data forms. Defaults to FALSE.

...

Optional character strings. One or more variable name from lpi_tall to calculate percent cover for, e.g. "GrowthHabitSub" to calculate percent cover by growth habits or "GrowthHabitSub", "Duration" to calculate percent cover for categories like perennial forbs, annual graminoids, etc.

Examples

# Gather header and LPI files
dsn = "Path/To/LMF_Geodatabase.gdb" # also contains species list
header <- gather_header(dsn = dsn,
                    source = "LMF")

lpi_tall <- gather_lpi(dsn = "Path/To/LMF_Geodatabase.gdb",
                    source = "LMF")

# Join lpi_tall and header to get the SpeciesState value associated with LPI data
lpi_tall <- dplyr::left_join(lpi_tall, header)

# Join species list attributes
species_join(data = lpi_tall,species_file = dsn)

# Calculate percent cover of individual species and cover values (S, R, etc) in lpi_tall
 pct_cover(lpi_tall = lpi_tall,
    tall = FALSE,
    hit = "any",
    by_line = FALSE,
    code)

 Calculate percent cover of Duration and Growth Habit Sub (e.g., to produce Annual Forb cover)
 pct_cover(lpi_tall = lpi_tall,
    tall = FALSE,
    hit = "any",
    by_line = FALSE,
    Duration, GrowthHabitSub)

smccord/terradactyl documentation built on Dec. 1, 2023, 7:37 p.m.