Learn R Programming

SHARK4R (version 1.0.2)

check_datatype: Validate SHARK system fields in a data frame

Description

This function checks whether the required and recommended global and datatype-specific SHARK system fields are present in a data frame.

Usage

check_datatype(data, level = "error")

Value

A tibble summarizing missing or empty fields, with columns:

  • level: "error" or "warning".

  • field: Name of the missing or empty field.

  • row: Row number where the value is missing (NA) or NA if the whole column is missing.

  • message: Description of the issue.

Arguments

data

A data.frame or tibble containing SHARK data to validate.

level

Character. The level of validation:

  • "error" (default) — checks only required fields.

  • "warning" — checks both required and recommended fields.

Details

  • Required fields: Missing or empty required fields are reported as errors.

  • Recommended fields: Missing or empty recommended fields are reported as warnings, but only if level = "warning" is specified.

Examples

Run this code
# Example with required fields missing
df <- data.frame(
  visit_year = 2024,
  station_name = NA
)
check_datatype(df, level = "error")

# Example checking recommended fields as warnings
check_datatype(df, level = "warning")

Run the code above in your browser using DataLab