View source: R/sw_dbW_WeatherDatabase.R
dbW_convert_to_GregorianYears | R Documentation |
This function can transfer from existing weather data to, e.g., different years / a subset of years (partially overlapping or not), or can convert from a non-leap to a Gregorian calendar.
dbW_convert_to_GregorianYears(
weatherData,
new_startYear = NULL,
new_endYear = NULL,
type = c("asis", "sequential"),
name_year = "Year",
name_DOY = "DOY",
name_data = weather_dataColumns(),
valNA = NULL
)
weatherData |
A list of elements of class |
new_startYear |
An integer value. The first Calendar year of the new
time period. If |
new_endYear |
An integer value. The last Calendar year of the new
time period. If |
type |
A string that affects how years of |
name_year |
A string. Column name of the weather data that corresponds to year. |
name_DOY |
A string. Column name of the weather data that corresponds to day of year. |
name_data |
A vector of strings. Column names of the weather data. |
valNA |
The (numerical) value of missing weather data.
If |
A data.frame formatted as a return object from function
dbW_weatherData_to_dataframe
with column names as given by
name_year
, name_DOY
, and name_data
.
The returned object may contain NA
, e.g., for
leap days that were added. Use function dbW_generateWeather
to fill in.
wdata <- rSOILWAT2::weatherData
## Transfer to different years (partially overlapping)
wnew <- dbW_convert_to_GregorianYears(
wdata,
new_startYear = 2000,
new_endYear = 2020
)
all.equal(unique(wnew[, "Year"]), 2000:2020)
anyNA(wnew) # --> use `dbW_generateWeather`
## Transfer to a subset of years (i.e., subset)
wnew <- dbW_convert_to_GregorianYears(
wdata,
new_startYear = 2000,
new_endYear = 2005
)
all.equal(unique(wnew[, "Year"]), 2000:2005)
anyNA(wnew)
## Correct/convert from a non-leap to a Gregorian calendar
wempty <- data.frame(
dbW_weatherData_to_dataframe(weatherHistory())
)[1:365, ]
wnew <- dbW_convert_to_GregorianYears(
wempty,
new_startYear = 2016,
new_endYear = 2016
)
all.equal(unique(wnew[, "Year"]), 2016:2016)
all.equal(nrow(wnew), 366) # leap year
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.