validate_data: Validate Data and Optionally Delete Missing Data

View source: R/validate_data.R

validate_dataR Documentation

Validate Data and Optionally Delete Missing Data

Description

The 2012 data of the federal database contains tract 18063, corner 2. There are boundaries recorded for that corner, nevertheless tree 14 has no azimuth measurement. This function therefore checks for the data sets not having missing data in the columns needed by get_correction_factors and optionally removes affected observations. It does not cross check whether missing data is really needed (azimuth is not when there is no boundary recorded for that tracts corner).

Usage

validate_data(x, type = c(NA, "angle_counts", "boundaries"), clean = FALSE)

Arguments

x

A tree or angle count data set.

type

The type of data, stick with the default to let us guess.

clean

Omit missing data? If the input contains missing data in the columns needed by get_correction_factors, the affected observations may be deleted. Otherwise an error is thrown.

Value

A tree data set. The input, if that was valid data, the cleaned input otherwise. Throws an error if columns are missing.

Examples

boundaries <- get(data("boundaries", package = "treePlotArea"))
nrow(boundaries)
nrow(validate_data(x = boundaries))
boundaries[1, "enr"] <- NA
try(validate_data(boundaries))
nrow(validate_data(boundaries, clean = TRUE))

treePlotArea documentation built on June 22, 2024, 6:57 p.m.