Learn R Programming

foqat (version 2.0.8.2)

trs: Resample time series by summary statistics

Description

Resamples time series by summary statistics, and returns complete time series with new time resolution. (wind data is acceptable)

Usage

trs(
  df,
  bkip,
  st = NULL,
  et = NULL,
  fun = "mean",
  probs = 0.5,
  na.rm = TRUE,
  wind = FALSE,
  coliws = 2,
  coliwd = 3,
  cpms = TRUE
)

Value

a dataframe which contains a time series for summary statistics with a new time resolution.

Arguments

df

dataframe of time series.

bkip

new resolution breaking input of time series, such as '1 hour'.

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?

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.

cpms

logical value. Compensate the insufficient amount of the millisecond bit for datetime column.

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

Run this code
trs(met, bkip = "1 hour", st = "2017-05-01 00:00:00", wind = TRUE, coliws = 4, coliwd = 5)

Run the code above in your browser using DataLab