@@ -3157,7 +3154,7 @@ fun_slide <- function(data, window.size, step, from = NULL, to = NULL, fun, args
# window.size: single numeric value indicating the width of the window sliding across data (in the same unit as data value)
# step: single numeric value indicating the step between each window (in the same unit as data value). Cannot be larger than window.size
# from: value of the left boundary of the first sliding window. If NULL, min(data) is used. The first window will strictly have from or min(data) as left boundary
# to: value of the left boundary of the last sliding window. If NULL, max(data) is used. Warning: (1) the final last window will not necessary have to or max(data) as left boundary but from|min(data) + n * step <= to|max(data); (2) if to argument is not specified, then the left boundary will be set according to the center of the last window such that [(from|min(data) + n * step + window.size) + (max(data) + n * step + window.size)] /2 <= max(data)
# to: value of the right boundary of the last sliding window. If NULL, max(data) is used. Warning: (1) the final last window will not necessary have to|max(data) as right boundary. In fact the last window will be the one that contains to|max(data) for the first time, i.e., min[from|min(data) + window.size + n * step >= to|max(data)]; (2) In fact, the >= in min[from|min(data) + window.size + n * step >= to|max(data)] depends on the boundary argument (>= for "right" and > for "left"); (3) to have the rule (1) but for the center of the last window, to argument has to be computed by hand such that min[(from|min(data) + n * step) + (from|min(data) + n * step + window.size)] /2 >= max(data)]
# fun: function or character string (without brackets) indicating the name of the function to apply in each window. Example: fun = "mean", or fun = mean
# arg: character string of additional arguments of fun (separated by a comma between the quotes). Example args = "na.rm = TRUE" for fun = mean. Ignored if NULL
# boundary: either "left" or "right". Indicates if the sliding window includes values equal to left boundary and exclude values equal to right boundary ("left") or the opposite ("right")
...
...
@@ -3174,6 +3171,7 @@ fun_slide <- function(data, window.size, step, from = NULL, to = NULL, fun, args
#$value : the computed value by the fun argument in each window)
tempo.log[min(which(tempo.log), na.rm = TRUE)] <- FALSE # convert the first left boundary that goes above max(data, na.rm = TRUE) to FALSE to keep it (the next ones will be removed)
wind <- wind[ ! tempo.log,]
}
left.log <- lapply(X = wind$left, Y = data, FUN = function(X, Y){
res <- get(left)(Y, X)
return(res)
...
...
@@ -7578,14 +7586,15 @@ return(output) # do not use cat() because the idea is to reuse the message
# add legend width from scatter. Ok with facet?
# add legend width from scatter (empty legend space notably). Ok with facet?
# transfert the 2nd tick part to scatter
# improve grid -> put secondary grids. Then trasfert to scatter
# replace .categ.legend.name by box.legend.name
# replace dot.categ.legend.name by dot.legend.name
# facet in bold and with variable name https://github.com/rstudio/cheatsheets/blob/master/data-visualization-2.1.pdf
# still errors to solve for these examples:
### errors
# obs1 <- data.frame(Time = 1:1000, Group1 = rep(c("G", "H"), times = 500), Group2 = rep(LETTERS[1:5], each = 200))