Unrolls the lagdays of data.frames.

unroll_physical_data(physical_data)

unroll_lagdays(df, n = 5)

Arguments

physical_data

list of river data (without hygiene)

df

data.frame of 2 columns: datum and var

n

numeric. unto to which day shall be lagged behind?

Value

Returns a list of data.frames for each variable. The data.frames contain the unrolled lagdays (with maxday = 5, length(df) == 17)

Functions

  • unroll_lagdays: Internal usage mostly

Examples

df1 <- data.frame(datum = rep("egal", 25), var = 1:25) df2 <- data.frame(datum = rep("egal", 25), var2 = 51:75, var3 = 101:125) unroll_lagdays(df1)
#> datum var var_abs_1 var_abs_2 var_abs_3 var_abs_4 var_abs_5 var_mean_12 #> 1 egal 1 NA NA NA NA NA NA #> 2 egal 2 1 NA NA NA NA NA #> 3 egal 3 2 1 NA NA NA NA #> 4 egal 4 3 2 1 NA NA NA #> 5 egal 5 4 3 2 1 NA NA #> 6 egal 6 5 4 3 2 1 4.5 #> 7 egal 7 6 5 4 3 2 5.5 #> 8 egal 8 7 6 5 4 3 6.5 #> 9 egal 9 8 7 6 5 4 7.5 #> 10 egal 10 9 8 7 6 5 8.5 #> 11 egal 11 10 9 8 7 6 9.5 #> 12 egal 12 11 10 9 8 7 10.5 #> 13 egal 13 12 11 10 9 8 11.5 #> 14 egal 14 13 12 11 10 9 12.5 #> 15 egal 15 14 13 12 11 10 13.5 #> 16 egal 16 15 14 13 12 11 14.5 #> 17 egal 17 16 15 14 13 12 15.5 #> 18 egal 18 17 16 15 14 13 16.5 #> 19 egal 19 18 17 16 15 14 17.5 #> 20 egal 20 19 18 17 16 15 18.5 #> 21 egal 21 20 19 18 17 16 19.5 #> 22 egal 22 21 20 19 18 17 20.5 #> 23 egal 23 22 21 20 19 18 21.5 #> 24 egal 24 23 22 21 20 19 22.5 #> 25 egal 25 24 23 22 21 20 23.5 #> var_mean_123 var_mean_1234 var_mean_12345 var_mean_2345 var_mean_345 #> 1 NA NA NA NA NA #> 2 NA NA NA NA NA #> 3 NA NA NA NA NA #> 4 NA NA NA NA NA #> 5 NA NA NA NA NA #> 6 4 3.5 3 2.5 2 #> 7 5 4.5 4 3.5 3 #> 8 6 5.5 5 4.5 4 #> 9 7 6.5 6 5.5 5 #> 10 8 7.5 7 6.5 6 #> 11 9 8.5 8 7.5 7 #> 12 10 9.5 9 8.5 8 #> 13 11 10.5 10 9.5 9 #> 14 12 11.5 11 10.5 10 #> 15 13 12.5 12 11.5 11 #> 16 14 13.5 13 12.5 12 #> 17 15 14.5 14 13.5 13 #> 18 16 15.5 15 14.5 14 #> 19 17 16.5 16 15.5 15 #> 20 18 17.5 17 16.5 16 #> 21 19 18.5 18 17.5 17 #> 22 20 19.5 19 18.5 18 #> 23 21 20.5 20 19.5 19 #> 24 22 21.5 21 20.5 20 #> 25 23 22.5 22 21.5 21 #> var_mean_45 var_mean_234 var_mean_23 var_mean_34 #> 1 NA NA NA NA #> 2 NA NA NA NA #> 3 NA NA NA NA #> 4 NA NA NA NA #> 5 NA NA NA NA #> 6 1.5 3 3.5 2.5 #> 7 2.5 4 4.5 3.5 #> 8 3.5 5 5.5 4.5 #> 9 4.5 6 6.5 5.5 #> 10 5.5 7 7.5 6.5 #> 11 6.5 8 8.5 7.5 #> 12 7.5 9 9.5 8.5 #> 13 8.5 10 10.5 9.5 #> 14 9.5 11 11.5 10.5 #> 15 10.5 12 12.5 11.5 #> 16 11.5 13 13.5 12.5 #> 17 12.5 14 14.5 13.5 #> 18 13.5 15 15.5 14.5 #> 19 14.5 16 16.5 15.5 #> 20 15.5 17 17.5 16.5 #> 21 16.5 18 18.5 17.5 #> 22 17.5 19 19.5 18.5 #> 23 18.5 20 20.5 19.5 #> 24 19.5 21 21.5 20.5 #> 25 20.5 22 22.5 21.5
summary(unroll_physical_data(list(var1 = df1, var2 = df2)))
#> Length Class Mode #> var1 17 data.frame list #> var2 33 data.frame list