Skip to content

Instantly share code, notes, and snippets.

View martinv13's full-sized avatar

Martin Vergier martinv13

View GitHub Profile
@martinv13
martinv13 / rlm.R
Created December 7, 2018 12:41
Rolling weighted linear model with exponential window computed in linear time.
# This gist demonstrate the use of a linear algorithm to compute exponentially weighted rolling linear regression between two time-series.
# benchmark rolling linear model using R's lm function
# output 2 regression coefficients + R2, ie 3 value per row
# alpha: decay coefficient (last weight = (1 - alpha) * previous weight)
# miny: minimum number of sample required to calculate an output value
rlm <- function(y, x, alpha, miny=10) {
n <- length(y)
@martinv13
martinv13 / module.R
Last active November 26, 2016 15:34
A simple Shiny module with input and output values
library(shiny)
testModuleInput <- function (id) {
ns <- NS(id)
uiOutput(ns("inputUI"))
}
testModule <- function (input, output, session, label) {
ns <- session$ns
value <- reactiveValues(value="")
@martinv13
martinv13 / iterativeTask.R
Last active November 26, 2016 11:07 — forked from trestletech/server.R
An example of interrupting a prolonged, iterative computation in Shiny.
library(shiny)
appUI <- pageWithSidebar(
# Application title
headerPanel("New Application"),
sidebarPanel(
"Progress: ",
textOutput("counter"),