Get startedGet started for free

First and last values of a vector

Consider these functions.

cppFunction('double fun1(NumericVector x) {
  return x[1];
}')

cppFunction('double fun2(NumericVector x) {
  int n = x.size();
  return x[n];
}')

Which statement is true?

This exercise is part of the course

Optimizing R Code with Rcpp

View Course

Hands-on interactive exercise

Turn theory into action with one of our interactive exercises

Start Exercise