add_WYD | R Documentation |
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).
add_WYD(df, datecolumn)
df |
a dataframe |
datecolumn |
quoted, requires a POSIXct formatted date or datetime |
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.
# 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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.