Description Usage Arguments Details Value See Also Examples
View source: R/summarize_rainfall.R
Uses daily site data to calculate summary rainfall statistics for an annual season.
1 2 3 4 5 6 7 8 9 10 11 12 | summarize_rainfall(
rain,
start_month,
end_month,
start_day = 15,
end_day = start_day,
rain_cutoff = 1,
na.rm = TRUE,
wide = TRUE,
id_index = 1,
date_sep = "_"
)
|
rain |
data frame with daily rainfall data for each site |
start_month |
numeric starting month defining season (inclusive) |
end_month |
numeric ending month defining season (inclusive) |
start_day |
numeric day of starting month defining season (inclusive); defaults to 15 |
end_day |
numeric day of ending month defining season (inclusive);
defaults to |
rain_cutoff |
numeric minimum value for daily rainfall to be counted as a rain day |
na.rm |
logical passed to summary statistic functions indicating
treatment of |
wide |
logical indicating whether or not to output as wide- formatted data |
id_index |
integer column index of unique site id |
date_sep |
character used to delimit variable prefix from date in column names; defaults to underscore ("_") |
User-defined seasons will be, at most, one year long, defined by the
start_*
and end_*
parameters. Seasons can span across
the new year, e.g. a season can start in November and end in March. Seasons
are enumerated by the year in which they start; i.e. if a season starts in
November and ends in March, the output for year YYYY will be based on the
data from November and December of YYYY and January, February, and March of
YYYY + 1.
By default, will return data in "long" format, with a column indicating the
year the data correspond to (but see discussion of season enumeration above).
If wide = TRUE
, output will include a separate column for each
statistic for each year (see Value). For example, if wide =
FALSE
and the data include daily measurements from 1997 to 2002, the output
will have a column year
and a column mean_season
. For these
same data, if wide = TRUE
, there will be no year
column, but
instead it will contain columns mean_season_1997
,
mean_season_1998
...mean_season_2002
.
tibble with rainfall summary statistics
If wide = FALSE
, returns values for each year for each site:
Mean rainfall for the season
Median rainfall for the season
Standard deviation of rainfall for the season
Total rainfall rainfall over the season
Skew of rainfall for the season, where skew is defined by (mean - median)/sd
Total number of days with rain less than rain_cutoff
Total number of days with rain greater than or equal to
rain_cutoff
Percentage of days in season with rain greater than
or equal to rain_cutoff
Longest stretch of days with less than rain_cutoff
contained within the period; if rainfall was less than rain_cutoff
for every day in defined season, the returned value will be zero
Number of consecutive days at beginning of season with
less than rain_cutoff
of measured rain; if first day of season had
rainfall greater than or equal to rain_cutoff
, the returned value
will be zero
Number of consecutive days at end of season with less
than rain_cutoff
of measured rain; if last day of season had
rainfall greater than or equal to rain_cutoff
, the returned value
will be zero
Mean total seasonal rainfall across all seasons
Standard deviation of total rainfall across all seasons
Mean number of days with rainfall less than
rain_cutoff
across all seasons
Standard deviation of number of days with rainfall
less than rain_cutoff
across all seasons
Mean number of days with rainfall greater than
or equal to rain_cutoff
across all seasons
Standard deviation of number of days with rainfall
greater than or equal to rain_cutoff
across all seasons
Mean percentage of days in season with
rain greater than or equal to rain_cutoff
across all seasons
Standard deviation of percentage of days
in season with rain greater than or equal to rain_cutoff
across all
seasons
Amount by which season total rainfall deviates from the mean total rainfall across seasons
Difference of total seasonal rainfall and mean of
total rainfall across seasons, divided by sd_period_total_season
Difference in number of days with rainfall greater than
or equal to rain_cutoff
from the mean number of days with rainfall
greater than or equal to rain_cutoff
across seasons
Difference in number of days with rainfall less than
rain_cutoff
from the mean number of days with rainfall less than
rain_cutoff
across seasons
Difference in percentage of days with rainfall
greater than or equal to rain_cutoff
from the percentage of days
with rainfall greater than or equal to rain_cutoff
across seasons
Difference in percentage of days with rainfall
greater than or equal to rain_cutoff
from
mean_period_percent_raindays
, divided by
sd_period_percent_raindays
If wide = TRUE
, all columns except those with *_period_* pattern are
replaced with one column for each year. For example, if the data include
daily measurements from 1997 to 2002, there will be no mean_season
column in the output, but will instead have columns mean_season_1997
,
mean_season_1998
...mean_season_2002
.
summarize_temperature
, par_summarize_rainfall
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | ## Not run:
# Season defined by 15 March through 15 November
rain_summary <- summarize_rainfall(rain = rain_2yr,
start_month = 3,
end_month = 11)
# As example above, but output in "long" format
rain_summary <- summarize_rainfall(rain = rain_2yr,
start_month = 3,
end_month = 11,
wide = FALSE)
# Season defined by 30 November through 15 March
rain_summary <- summarize_rainfall(rain = rain_2yr,
start_month = 11,
end_month = 3,
start_day = 30,
end_day = 15)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.