#' sub_window function
#'
#' @param matrix binary matrix consisting of 1's and 0's.
#' @param width number of columns for each subwindow
#'
#' @return a list of non-overlapping, equally sized windows
#' @export
#'
#' @examples x=window(matrix,width)
#' @importFrom magrittr %>%
#account for slightly uneven windows
sub_window<-function(matrix,width){
begin=1
sub_win=list()
#adjust so we don't get floating points as indicies
num_windows=ceiling(ncol(matrix)/width)
for(i in 1:num_windows){
if(i==num_windows){
sub_win[[i]]=matrix[,(begin:(ncol(matrix)))]
return(sub_win)
}
sub_win[[i]]=matrix[,(begin:(width*i))]
begin=width*i+1
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.