#' Reverse the order of elements in a vector.
#'
#' @param x, A vector.
#'
#' @return A vector with elements \code{y[i] <- x[length(x)-i+1]}
#' @export
#'
#' @examples reverse(c(1,2,3))
reverse <- function(x){
if (!is.null(dim(x))){
return("Arguments must be 1 dimensional")
}
x.rev <- rep(0,length(x))
for (i in 1:length(x)){
x.rev[i] <- x[length(x)-i+1]
}
return(x.rev)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.