1. 学习
  2. /
  3. 课程
  4. /
  5. Optimizing R Code with Rcpp

Connected

练习

Boiler plate

As you saw in the previous exercise, the code below does not compile.

#include <Rcpp.h>
using namespace Rcpp ; 

double twice(double x){
    return x + x
}

Let's modify it.

说明

100 XP
  • Fix the syntax error on the function's return line (line 8).
  • Add an [[Rcpp::export]] decorator so that the function is exported to R.