gr_check_data: Check the correctness of data frame for separating

View source: R/separate.R

gr_check_dataR Documentation

Check the correctness of data frame for separating

Description

This function is called inside gr_separate(), but can be used explicitly inside your code.

Usage

gr_check_data(df)

Arguments

df

data.frame with four columns: date, runoff, temperature, precipitation, as required by gr_separate().

Value

stops execution if df contains the wrong number of columns, or the columns have the wrong types, or the data in columns is incorrect (e.g. runoff or precipitation are negative).

Examples

library(grwat)

# example Spas-Zagorye data is included with grwat package
data(spas)
head(spas)

gr_check_data(spas)

# raw Spas-Zagorye data represents date components
# in columns and does not contain meteorologgical variables
path = system.file("extdata", "spas-zagorye.txt", 
                   package = "grwat")

hdata_raw = read.delim(path, header = FALSE, 
                       sep = ' ', na.strings = c('-999', '-999.0', '-'),
                       col.names = c('d', 'm', 'y', 'q'))

print(hdata_raw)

try(gr_check_data(hdata_raw))




grwat documentation built on Nov. 2, 2023, 5:21 p.m.