GithubHelp home page GithubHelp logo

slider's Introduction

Travis-CI Build Status

SlideR

SlideR: An R package for Sliding Windows using dplyr, purrr and tidyr. The package creates a nested data.frame with the columns; key, w_size and data.

Installation

The package is in development and can be downloaded with devtools:

# install.packages("devtools")
devtools::install_git("https://www.gitlab.com/mmp-uva/slider.git")

Requirements

The package requires the following packages:

  • dplyr (install.packages("tidyverse"))
  • purrr (install.packages("purrr"))
  • tidyr (install.packages("tidtyr"))

You can also install all these packages (and more) with one package:

  • tidyverse (install.packages("tidyverse"))

Usage

To load the package:

library(slider)

Partition data using a sliding window

x <- 1:100
slide_window(x, w_size=10)

When using data.frames, a key needs to specified. The key defines which column is used as key to the different windows.

df <- data.frame(x = 1:100, y=c("a", "b"))
slide_window(df, key="x", w_size=10)

Partition data using multiple sliding windows

It is often useful to apply multiple sliding windows to the same data, while varying the size of the window.

This can be achieved using slide_windows

x <- 1:100
slide_windows(x, w_sizes=c(5, 10, 15))

Apply a function to each window

In most cases the sliding window is used to apply a function to segments of the data. The function apply_slide_window and apply_slide_windows provide this functionality:

x <- 1:100
apply_slide_window(x, mean, w_size=10)
# or
apply_slide_windows(x, mean, w_sizes=c(5, 10, 15))

For data.frames it is a bit more complicated, as one needs to specify the column name within the window.

df <- data.frame(x = 1:100, y=c("a", "b"))
apply_slide_windows(df, ~mean(.$x), key="x", w_sizes=10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.