extractWindowAroundIndices: returns windows aroung increasing series by group indices

Description Usage Arguments Value Examples

View source: R/utility_functions.R

Description

returns windows aroung increasing series by group indices

Usage

1
extractWindowAroundIndices(df, windowLength, startIndices, groupingVariable)

Arguments

df

Input dataframe, should contain a grouping column called groupingVariable

startIndices

Should contain the indices as start from the grouped series

groupingVariable

The name of the column that will be used for the inned join

windowLenght

Must be an odd number

Value

A new data frame containing just the matching columns

Examples

1
2
3
4
5
6
A <- data.frame(name = "A", valNumeric = c(1:9), valCategorical = c("YES","NO","MAYBE"))
B <- data.frame(name = "B", valNumeric = c(5:100), valCategorical = c('YES','NO'))
C <- data.frame(name = "C", valNumeric = c(5:7), valCategorical = c('green','green','blue'))
df <- rbind(A,B,C)
startIndices <- data.frame(name = c("A","B","C"), index = c(3,10,2))
ggplot(extractWindowAroundIndices(df, 5, startIndices, "name"), aes(position, valNumeric, color = name)) + geom_line()

alesaccoia/alexr documentation built on Dec. 19, 2021, 12:26 a.m.