#' @export
r_cshift <- function(x, n) {
lx <- length(x)
# stopifnot(is_scalar_integerish(n), abs(n) < lx)
# storage.mode(n) <- "integer"
n <- as.integer(n)
if (n < 0L)
n <- lx+n
x[c( (n+1L):lx, 1L:n)]
}
if(FALSE) {
x <- as.numeric(1:1000)
n <- 20
r <- bench::mark(cshift(x, n), r_cshift(x, n), min_time = 2)
plot(r)
library(dplyr)
r %>%
mutate(per_diff = as.numeric(median / median[1])) %>%
select(per_diff, everything())
str(cshift(as.numeric(1:10), 3))
str(cshift(as.integer(1:10), 3))
str(cshift(as.complex(1:10), 3))
# str(cshift(as.character(1:10), 3))
# str(cshift(as.list(1:10), 3))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.