#' Display slices of the object
#'
#' Returns n elements of the object taken in even intervals.
#'
#' @param x object
#' @param n a single integer. Size for the resulting object:
#' number of elements for a vector (including lists),
#' rows for a matrix or data frame.
#'
#' @export
slices <- function(x, n = 6L) UseMethod("slices")
#' @export
slices.default <- function(x, n = 6L) {
x[seq(1, length(x), length.out = n)]
}
#' @export
slices.list <- function(x, n = 6L) {
x[seq(1, length(x), length.out = n)]
}
#' @export
slices.matrix <- function(x, n = 6L) {
x[seq(1, nrow(x), length.out = n), ]
}
#' @export
slices.data.frame <- function(x, n = 6L) {
x[seq(1, nrow(x), length.out = n), ]
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.