makeElement = function(data, name) {
div(style = "border-width:2px;border-style:solid;", drag = name,
div(class = "active title", name),
div(class = "active content", p(sprintf("Class: %s", class(data[[name]])))))
}
add_time = function(data, var.temp){
if(var.temp == "None") tibble::rowid_to_column(data, "temps")
else dplyr::rename(data, "temps" = var.temp)
}
freq = function(timestamp){
if(timestamp == "Quotidienne") frequency.ts = 364.25
else if(timestamp == "Mensuelle") frequency.ts = 12
else if(timestamp == "Trimestrielle") frequency.ts = 4
else frequency.ts = NULL
return(frequency.ts)
}
adjust_season = function(data, seasonal.adjustment, timestamp){
if(seasonal.adjustment == TRUE) mutate(data, x = x - decompose(ts(data$x, frequency = freq(timestamp)))$seasonal)
else data
} # remplacer par un simple muitate_if ...
add_trend = function(data, trend, auto.trend, trend.order, timestamp){
if(trend == TRUE & auto.trend == TRUE) mutate(data, trend = decompose(ts(data$x, frequency = freq(timestamp)))$trend)
else if(trend == TRUE & auto.trend == FALSE) mutate(data, trend = ma(data$x, order = trend.order))
else data
}
add_plot_trend = function(pl, trend, auto.trend, trend.order){
if(trend == TRUE & auto.trend == TRUE) add_trace(pl, y = ~ trend, mode = 'lines', name = "Trend (auto)")
else if(trend == TRUE & auto.trend == FALSE) add_trace(pl, y = ~ trend, mode = 'lines', name = paste0("Trend (manuel)\n MA(", trend.order, ")"))
else pl
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.