## ----include = FALSE----------------------------------------------------------
# nolint start: indentation-linter
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.width = 7,
  fig.height = 5
  )
# nolint end

## ----setup--------------------------------------------------------------------
library(daisytools)

## -----------------------------------------------------------------------------
data_dir <- system.file("extdata", package="daisytools")
dlfs <- read_dlf(file.path(data_dir, "annual"))
names(dlfs)

## -----------------------------------------------------------------------------
colnames(dlfs[[1]]@data)
colnames(dlfs[[8]]@data)

## -----------------------------------------------------------------------------
dlfs <- dlfs[c(1, 2, 3, 4)]
names(dlfs)
dlfs <- drop_dir_from_names(dlfs)
dlfs <- strip_common_prefix_from_names(dlfs)
names(dlfs)

## -----------------------------------------------------------------------------
colnames(dlfs[[1]]@data)

## -----------------------------------------------------------------------------
y_vars <- c("Surface_Loss", "Denitrification")
plot_dlf(dlfs, "year", y_vars, type="bar")

## -----------------------------------------------------------------------------
plot_dlf(dlfs, "year", y_vars, "lines")
plot_dlf(dlfs, "year", y_vars, "points")
plot_dlf(dlfs, "year", y_vars, "lines-points-bar")

## -----------------------------------------------------------------------------
path <- file.path(data_dir, "hourly/P2D-Daily-Soil_Chemical_110cm.dlf")
dlf <- read_dlf(path)
colnames(dlf@data)

## -----------------------------------------------------------------------------
y_vars <- c("Leak_Matrix", "Transform")
plot_dlf(dlf, "time", y_vars, "points")

## -----------------------------------------------------------------------------
summer95 <- subset_dlf(dlf, "1995-06-01", "1995-08-31")
plot_dlf(summer95, "time", y_vars, "lines", title_suffix=" - Summer of '95")

## -----------------------------------------------------------------------------
data_dir <- system.file("extdata", package="daisytools")
path <- file.path(data_dir, "daisy-spawn-like")
dlfs <- read_dlf(path)
names(dlfs)

## -----------------------------------------------------------------------------
colnames(dlfs$Harvest@data)
plot_dlf(dlfs$Harvest, "time", "leaf_DM", "lines")

## -----------------------------------------------------------------------------
colnames(dlfs$`FWater200-Y`@data)
plot_dlf(dlfs$`FWater200-Y`, "time", "Irrigation", "bar")

## -----------------------------------------------------------------------------
data_dir <- system.file("extdata", package="daisytools")
path <- file.path(data_dir, "daily/DailyP/DailyP-Daily-WaterFlux.dlf")
dlf <- read_dlf(path)
head(dlf)

## -----------------------------------------------------------------------------
plot_dlf_depth(dlf, "q")

## -----------------------------------------------------------------------------
plot_dlf_depth(dlf, "q", c("1990-04-23", "1990-04-27"))

