शुरू करेंमुफ़्त में शुरू करें

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.

यह अभ्यास पाठ्यक्रम का हिस्सा है

Optimizing R Code with Rcpp

पाठ्यक्रम देखें

अभ्यास निर्देश

  • 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.

इंटरैक्टिव व्यावहारिक अभ्यास

इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।

#include 
using namespace Rcpp ; 

// Export the function to R

double twice(double x) {
    // Fix the syntax error
    return x + x
}
कोड संपादित करें और चलाएँ