Nothing
#' Fold a vector onto itself
#'
#' @param x a vector
#' @param block.size the size of groups in which to block the data
#' @return a new vector in the following order: first block, last block, second
#' block, second-to-last block, ...
#'
#' @references from the seemingly now defunct \code{mRchmadness} package by Eli
#' Shayer and Saber Powers and used per the terms of that package's GPL-2
#' license
fold <- function(x, block.size = 1) {
num.blocks <- length(x) / block.size
# Sanitize inputs
if (length(x) %% block.size != 0) {
stop("length(x) / block.size must be an integer.")
}
if (num.blocks %% 2 != 0) {
stop("Number of blocks must be even.")
}
# Split by block
blocks <- split(x, rep(1:num.blocks, each = block.size))
names(blocks) <- NULL
# Fold by block
unlist(blocks[order(c(1:(num.blocks/2), (num.blocks/2):1))])
}
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.