CommencerCommencer gratuitement

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?

Cet exercice fait partie du cours

Optimizing R Code with Rcpp

Afficher le cours

Exercice interactif pratique

Passez de la théorie à la pratique avec l’un de nos exercices interactifs

Commencer l’exercice