avri: Calculate average of variation

Description Usage Arguments Details Value Examples

View source: R/avri.R

Description

Calculates average of variation of time series. (contain but not limited to: average daily variation, average monthly variation, average annual variation)

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
avri(
  df,
  bkip,
  mode = "recipes",
  value = "day",
  colid = 1,
  st = NULL,
  et = NULL,
  na.rm = TRUE,
  digits = 2,
  wind = FALSE,
  coliws = 2,
  coliwd = 3
)

Arguments

df

dataframe of time series.

bkip

the basic time reslution for average variation, such as '1 hour'.

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.

colid

column index for date-time. The default value is 1.

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.

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.

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'.

Value

a dataframe. The first column is the serial number within the period. The average variation start from the second column.
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.

Examples

1
2
avri(met, bkip = "1 hour", mode = "recipes", value = "day",
st = "2017-05-01 00:00:00", wind = TRUE, coliws = 4, coliwd = 5)

GlossyBoat/foqat documentation built on Jan. 18, 2021, 11:31 p.m.