read_BWB_rain_correction_long: Read BWB Rain Correction Data

View source: R/bwb_rain_correction.R

read_BWB_rain_correction_longR Documentation

Read BWB Rain Correction Data

Description

Read BWB Rain Correction Data in "long" format. The data is provided by BWB in the form of an Excel file. Save the file to CSV and run this function on that CSV file.

Usage

read_BWB_rain_correction_long(
  files,
  sep = ";",
  country = c("de", "en")[1],
  date.format = "%A %d. %B %Y",
  locale = .localeString(country),
  wide = TRUE,
  dbg = TRUE
)

Arguments

files

full path to CSV file containing rain height correction data in "long" format

sep

column separator in files

country

one of "de" (German) or "en" (English) according to the format numeric strings are given in

date.format

format used to convert the date string into a date object

locale

locale string, passed to read_BWB_rain_correction_long

wide

if TRUE (default) the data will be returned in "wide" format, i.e. with the date in the first column and each further column representing a rain gauge

dbg

logical. If TRUE, debug messages are shown.

Value

data frame either in "wide" format (with the date in the first column and the rain heights in the following columns named according to the "object ids" of the rain gauges) or in "long" format (with columns Date, ObjNr Pumpwerk Niederschlag). The mapping between object ids and gauge names is returned in the attribute "gauges".

Examples

## Not run: 
# Provide the path to an example file in this package
file <- "Niederschlag_example.csv"
file <- system.file("extdata", file, package = "kwb.read")
  
# Read the CSV file into a data frame in "long" format
correction.wide <- read_BWB_rain_correction_long(file)
  
# Read the CSV file into a data frame in "wide" format (gauges in columns)
correction.long <- read_BWB_rain_correction_long(file, wide = FALSE)
  
# Get the mapping between object IDs and gauge names from attribute "gauges"
kwb.utils::getAttribute(correction.wide, "gauges")

## End(Not run)

KWB-R/kwb.read documentation built on Oct. 2, 2023, 10:40 a.m.