Learn R Programming

grwat (version 0.0.4)

gr_check_data: 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)

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).

Arguments

df

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

Examples

Run this code
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))



Run the code above in your browser using DataLab