Skip to contents

Compute the variation of summary statistics for time series.

Usage

svri(
  df,
  bkip = NULL,
  mode = "recipes",
  value = "day",
  st = NULL,
  et = NULL,
  fun = "mean",
  probs = 0.5,
  na.rm = TRUE,
  digits = 2,
  wind = FALSE,
  coliws = 2,
  coliwd = 3,
  sn = FALSE
)

Arguments

df

dataframe of time series.

bkip

the basic time reslution for variation, such as '1 hour'. If mode "custom" is selected, do not need to enter bkip.

mode

for calculating cycles: "recipes", "ncycle", "custom". "recipes" means using internal setting for calculation. "ncycle" means setting number of items for per cycle. "custom" means using 1 column in dataframe as a list of grouping elements for calculation.

value

for detail setting of mode. Possible values for "recipes" are "day", "week", "month", year". "day" equals to 24 (hours) values in 1 day. "week" equals to 7 (days) values in 1 week. "month" equals to 31 (days) values in 1 month. "year" equals to 12 (months) values in 1 year. values for "ncycle" is a number representing number of items in per cycle. values for "custom" is a number representing column index in dataframe.

st

start time of resampling. The default value is the fisrt value of datetime column.

et

end time of resampling. The default value is the last value of datetime column.

fun

a function to compute the summary statistics which can be applied to all data subsets: 'sum', 'mean', 'median', 'min', 'max', 'sd' and 'quantile'.

probs

numeric vector of probabilities with values in \([0,1]\).

na.rm

logical value. Remove NA value or not?

digits

numeric value, digits for result dataframe.

wind

logical value. if TRUE, please set coliwd, coliws.

coliws

numeric value, column index of wind speed in dataframe.

coliwd

numeric value, column index of wind direction (degree) in dataframe.

sn

logical value. if TRUE, the results will be presented by scientific notation (string).

Value

the variation of summary statistics Note that when the pattern USES "ncycle" or "custom", the start time determines the start time of the first element in the average variation. For example, if the first timestamp of data is "2010-05-01 12:00:00", the resolution is 1 hour, the mode is "ncycle", and the value is 24, then the result represents diurnal variation starting from 12 o'clock.

Details

If you have wind data (wind speed, and wind direction in dgree), please set 'wind' as 'TRUE', and set values for 'coliwd' and 'coliws'.

Examples

svri(met, bkip = "1 hour", mode = "recipes", value = "day", fun = 'quantile', probs=0.5,
st = "2017-05-01 00:00:00")
#> Joining, by = "temp_datetime"
#>    hour of day      TEM      HUM       WS        WD
#> 1            0 17.87500 88.10000 1.700000  80.50000
#> 2            1 18.47500 91.05000 1.983333 115.66667
#> 3            2 18.09167 90.96667 1.733333 117.00000
#> 4            3 18.25000 83.11667 1.816667 112.58333
#> 5            4 18.52500 81.37500 1.766667 117.91667
#> 6            5 17.80417 88.11667 1.037500 128.70833
#> 7            6 19.70417 82.95417 1.437500 107.20833
#> 8            7 21.78750 67.86667 2.145833 128.58333
#> 9            8 22.95833 55.80833 2.687500 129.41667
#> 10           9 24.37917 51.76667 2.583333 133.25000
#> 11          10 25.02083 48.26250 2.712500 145.91667
#> 12          11 25.47500 47.15417 2.529167 139.91667
#> 13          12 25.72083 42.46250 3.241667 120.33333
#> 14          13 25.78333 37.57917 3.425000 115.29167
#> 15          14 25.90417 38.17917 3.291667 100.50000
#> 16          15 25.60833 39.17917 3.704167  84.33333
#> 17          16 24.42917 47.39583 4.183333  85.50000
#> 18          17 23.72500 52.70000 3.920000  85.30000
#> 19          18 22.21667 56.37500 2.800000 101.83333
#> 20          19 20.50833 63.16667 1.758333  96.00000
#> 21          20 19.25833 74.72500 2.116667  91.83333
#> 22          21 18.76667 77.68333 1.725000 107.75000
#> 23          22 18.52500 76.11667 1.591667  95.25000
#> 24          23 18.40000 83.22500 1.541667 131.50000