Tutorial by Examples

Consider the following tough-to-vectorize for loop, which creates a vector of length len where the first element is specified (first) and each element x_i is equal to cos(x_{i-1} + 1): repeatedCosPlusOne <- function(first, len) { x <- numeric(len) x[1] <- first for (i in 2:len) { ...
Following the Rcpp example in this documentation entry, consider the following tough-to-vectorize function, which creates a vector of length len where the first element is specified (first) and each element x_i is equal to cos(x_{i-1} + 1): repeatedCosPlusOne <- function(first, len) { x <-...

Page 1 of 1