Skip to contents

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
)

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.

Value

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

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

trs(met, bkip = "1 hour", st = "2017-05-01 00:00:00", wind = TRUE, coliws = 4, coliwd = 5)
#> Joining, by = "temp_datetime"
#>                    Time      TEM      HUM        WS        WD
#> 1   2017-05-01 00:00:00 20.95833 85.60000 3.3613210  74.90716
#> 2   2017-05-01 01:00:00 21.18333 83.15833 4.5554271  72.52891
#> 3   2017-05-01 02:00:00 21.54167 77.62500 4.2382921  72.02753
#> 4   2017-05-01 03:00:00 20.71667 80.22500 5.2876112  82.34847
#> 5   2017-05-01 04:00:00 20.52500 79.80000 5.6539177  89.15400
#> 6   2017-05-01 05:00:00 21.12500 61.41667 7.4174296  98.62400
#> 7   2017-05-01 06:00:00 21.30000 51.44167 8.4019393  89.26818
#> 8   2017-05-01 07:00:00 21.47500 49.79167 8.8107977  91.82857
#> 9   2017-05-01 08:00:00 22.59167 45.15000 9.0438628  95.76847
#> 10  2017-05-01 09:00:00 24.05000 36.04167 9.8062919  93.69047
#> 11  2017-05-01 10:00:00 24.66667 32.87500 9.7996062  93.71851
#> 12  2017-05-01 11:00:00 25.41667 32.38333 8.7989544  95.03462
#> 13  2017-05-01 12:00:00 25.40833 32.85000 8.2255104  86.10999
#> 14  2017-05-01 13:00:00 25.19167 33.29167 7.9717552  92.43260
#> 15  2017-05-01 14:00:00 24.99167 36.41667 7.3205773  83.35597
#> 16  2017-05-01 15:00:00 24.64167 39.42500 6.3592364  94.70823
#> 17  2017-05-01 16:00:00 23.80000 46.40833 5.2421909  90.57212
#> 18  2017-05-01 17:00:00 22.15000 52.70000 5.4547693  76.49225
#> 19  2017-05-01 18:00:00 20.86667 56.37500 4.7521307  82.08415
#> 20  2017-05-01 19:00:00 19.65000 59.80000 3.7933269  95.86839
#> 21  2017-05-01 20:00:00 19.03333 63.64167 2.8289010  81.86883
#> 22  2017-05-01 21:00:00 18.47500 70.39167 1.4950736 105.22067
#> 23  2017-05-01 22:00:00 17.67500 76.11667 1.1332237  88.54883
#> 24  2017-05-01 23:00:00 17.79167 83.22500 1.4958834  82.47690
#> 25  2017-05-02 00:00:00 17.35833 88.10000 1.6854231  88.01894
#> 26  2017-05-02 01:00:00 17.10833 91.05000 1.9648708 115.78985
#> 27  2017-05-02 02:00:00 17.48333 90.96667 1.5692981 129.42215
#> 28  2017-05-02 03:00:00 17.62500 83.11667 1.7797199 129.09467
#> 29  2017-05-02 04:00:00 17.13333 81.37500 1.7613731 117.84590
#> 30  2017-05-02 05:00:00 17.54167 83.74167 0.4075899 158.10313
#> 31  2017-05-02 06:00:00 19.70000 81.32500 0.9803553 109.12993
#> 32  2017-05-02 07:00:00 22.10000 70.93333 1.9545882 121.08631
#> 33  2017-05-02 08:00:00 23.32500 57.00000 3.2744329 112.59190
#> 34  2017-05-02 09:00:00 24.70833 48.72500 3.0353402 116.86109
#> 35  2017-05-02 10:00:00 25.37500 44.80000 2.9034848 112.00032
#> 36  2017-05-02 11:00:00 25.53333 46.33333 2.6034571 160.65738
#> 37  2017-05-02 12:00:00 26.03333 39.25833 2.6315118 153.62605
#> 38  2017-05-02 13:00:00 26.37500 33.72500 2.1191908 147.89144
#> 39  2017-05-02 14:00:00 26.72500 26.75833 2.6544794 117.85194
#> 40  2017-05-02 15:00:00 26.57500 36.76667 3.0531927  74.28852
#> 41  2017-05-02 16:00:00 24.51667 48.38333 4.4521283  74.65813
#> 42  2017-05-02 17:00:00 24.02727 47.84545 4.2451937  91.59472
#> 43  2017-05-02 18:00:00 22.69167 47.40833 4.4571483  90.83857
#> 44  2017-05-02 19:00:00 20.95833 56.16667 3.5175220  91.80451
#> 45  2017-05-02 20:00:00 20.32500 60.04167 3.2120850  91.95136
#> 46  2017-05-02 21:00:00 20.65000 61.20833 2.9180196  98.08057
#> 47  2017-05-02 22:00:00 19.83333 72.90833 1.9463060  98.50326
#> 48  2017-05-02 23:00:00 20.44167 74.73333 1.5383836 136.12584
#> 49  2017-05-03 00:00:00 22.00000 60.38333 2.1831115 157.63100
#> 50  2017-05-03 01:00:00 22.28333 52.39167 2.9878708 169.81148
#> 51  2017-05-03 02:00:00 21.68333 55.69167 2.7885134 119.00745
#> 52  2017-05-03 03:00:00 20.25833 60.12500 3.3437185 115.94502
#> 53  2017-05-03 04:00:00 19.70000 66.05000 3.8982121 140.33268
#> 54  2017-05-03 05:00:00       NA       NA        NA        NA
#> 55  2017-05-03 06:00:00       NA       NA        NA        NA
#> 56  2017-05-03 07:00:00       NA       NA        NA        NA
#> 57  2017-05-03 08:00:00       NA       NA        NA        NA
#> 58  2017-05-03 09:00:00       NA       NA        NA        NA
#> 59  2017-05-03 10:00:00       NA       NA        NA        NA
#> 60  2017-05-03 11:00:00       NA       NA        NA        NA
#> 61  2017-05-03 12:00:00       NA       NA        NA        NA
#> 62  2017-05-03 13:00:00       NA       NA        NA        NA
#> 63  2017-05-03 14:00:00       NA       NA        NA        NA
#> 64  2017-05-03 15:00:00       NA       NA        NA        NA
#> 65  2017-05-03 16:00:00       NA       NA        NA        NA
#> 66  2017-05-03 17:00:00 21.16000 63.12000 3.6527150  86.53106
#> 67  2017-05-03 18:00:00 20.09167 64.15000 2.2760769 114.22838
#> 68  2017-05-03 19:00:00 19.12500 72.25000 1.1691119  85.41128
#> 69  2017-05-03 20:00:00 18.71667 79.34167 2.0460630  76.20149
#> 70  2017-05-03 21:00:00 18.60833 83.82500 2.2997614  84.79404
#> 71  2017-05-03 22:00:00 18.52500 86.71667 2.3298298  78.62252
#> 72  2017-05-03 23:00:00 17.85000 88.95000 1.5210860  92.33331
#> 73  2017-05-04 00:00:00 17.87500 91.28333 1.4358910  79.82633
#> 74  2017-05-04 01:00:00 18.47500 91.55833 1.5142924  77.26144
#> 75  2017-05-04 02:00:00 18.09167 92.31667 1.6992485  85.19831
#> 76  2017-05-04 03:00:00 18.25000 93.43333 1.6844995  87.74733
#> 77  2017-05-04 04:00:00 18.52500 93.96667 1.6404311  90.99324
#> 78  2017-05-04 05:00:00 18.02500 94.50833 1.4287874 110.22221
#> 79  2017-05-04 06:00:00 19.56667 89.93333 1.7837357 102.14691
#> 80  2017-05-04 07:00:00 21.12500 78.50833 2.2398957 135.48524
#> 81  2017-05-04 08:00:00 22.55833 65.24167 1.7975903 146.40380
#> 82  2017-05-04 09:00:00 23.92500 54.80833 1.9214424 149.30905
#> 83  2017-05-04 10:00:00 24.60000 55.16667 1.1385130 186.12286
#> 84  2017-05-04 11:00:00 25.29167 55.60833 1.7891248 111.96015
#> 85  2017-05-04 12:00:00 24.70833 66.57500 3.2759984  76.00658
#> 86  2017-05-04 13:00:00 25.11667 62.59167 3.0762681  61.66010
#> 87  2017-05-04 14:00:00 25.08333 57.20000 3.5769392  65.37774
#> 88  2017-05-04 15:00:00 24.25000 52.40833 4.0011855  73.96865
#> 89  2017-05-04 16:00:00 24.34167 49.90833 3.6195604  80.78818
#> 90  2017-05-04 17:00:00 23.72500 53.72500 3.3695366  79.33004
#> 91  2017-05-04 18:00:00 22.21667 61.29167 2.2148164 100.80749
#> 92  2017-05-04 19:00:00 20.50833 70.45833 1.7132580 100.22781
#> 93  2017-05-04 20:00:00 19.25833 79.67500 0.8524930 108.63973
#> 94  2017-05-04 21:00:00 18.76667 86.89167 0.8054163 111.23297
#> 95  2017-05-04 22:00:00 18.20000 90.91667 0.3658136  86.35082
#> 96  2017-05-04 23:00:00 18.40000 93.38333 0.6818333   1.59145
#> 97  2017-05-05 00:00:00 17.60000 94.46667 1.1866624  10.89541
#> 98  2017-05-05 01:00:00 17.40833 94.62500 1.0011603 344.36505
#> 99  2017-05-05 02:00:00 17.25833 93.69167 0.9773897 317.36737
#> 100 2017-05-05 03:00:00 17.00833 93.31667 1.0784426 351.84611
#> 101 2017-05-05 04:00:00 17.02500 93.20833 0.6599958 324.17318
#> 102 2017-05-05 05:00:00 17.58333 92.49167 0.5677873 319.25926
#> 103 2017-05-05 06:00:00 19.70833 84.58333 0.9347514 332.62104
#> 104 2017-05-05 07:00:00 22.46667 64.80000 1.1179763 313.91077
#> 105 2017-05-05 08:00:00 24.51667 54.61667 1.2627566 279.05430
#> 106 2017-05-05 09:00:00 25.46667 55.27500 1.9219750 263.74235
#> 107 2017-05-05 10:00:00 26.30833 51.72500 2.0457982 253.32670
#> 108 2017-05-05 11:00:00 27.73333 47.97500 2.0809749 263.71828
#> 109 2017-05-05 12:00:00 28.74167 45.66667 2.9618384 277.42218
#> 110 2017-05-05 13:00:00 29.64167 41.43333 3.2702249 286.07507
#> 111 2017-05-05 14:00:00 30.45000 39.94167 2.6354064 268.48894
#> 112 2017-05-05 15:00:00 30.65833 38.93333 2.8462334 273.39633
#> 113 2017-05-05 16:00:00 30.71667 38.72500 2.6710322 264.47083
#> 114 2017-05-05 17:00:00 30.48333 39.07500 2.3198433 259.97816
#> 115 2017-05-05 18:00:00 29.31667 48.57500 1.0694837 218.69908
#> 116 2017-05-05 19:00:00 26.32500 63.16667 1.2955812 188.93140
#> 117 2017-05-05 20:00:00 24.55000 74.72500 1.6635416 190.64213
#> 118 2017-05-05 21:00:00 24.07500 77.68333 1.5306479 199.22702
#> 119 2017-05-05 22:00:00 23.90833 74.93333 1.5587007 205.64651
#> 120 2017-05-05 23:00:00 23.02500 77.45000 1.5153250 197.45880