add_WYD: Add Day of Year, Day of Water Year.

View source: R/add_WYD.R

add_WYDR Documentation

Add Day of Year, Day of Water Year.

Description

This function takes a POSIXct formatted column name and adds new columns to a dataframe for Day of Year (Julian), Day of Water Year (starting Oct 1 and ending Sep 30), and Water Year (from Oct 1 to Sep 30).

Usage

add_WYD(df, datecolumn)

Arguments

df

a dataframe

datecolumn

quoted, requires a POSIXct formatted date or datetime

Details

This function should be used as follows: Reassign or create the dataframe you would like to add new Water Year columns to. This function will generate three new columns, DOY (Day of Year), WY (Water Year, starting Oct 1), and DOWY (Day of Water Year, starting Oct 1). It relies on dowy and wt_yr functions, as well as the lubridate package.

Examples


# get data
airq <- datasets::airquality
# add a year (this data from 1973)
airq$year <- 1973
# make a date col
airq$date <- with(airq, paste0(year, "-", Month, "-", Day))
head(airq)
# now format into POSIX with lubridate
require(lubridate)
airq$date <- lubridate::ymd(airq$date)

# now run function:
airq <- add_WYD(airq, "date")


ryanpeek/wateRshedTools documentation built on Jan. 6, 2023, 7:06 a.m.