2016-04-03 75 views
0

我正在运行中的R-Studio给出下面的C++代码RCPP错误:意外 '/' 中的 “/”

# include<Rcpp.h> 
using namespace Rcpp; 

// [[Rcpp::export]] 
NumericVector timesTwo(NumericVector x) { 
     return x * 2; 
    } 

/*** R 
    timesTwo(42) 

*/ 

2错误的类型来了:

Error: unexpected symbol in "using namespace"

Error: unexpected '/' in "/"

回答

3

你有

# include<Rcpp.h> 

所以尝试#后除去空间产生

#include<Rcpp.h> 

如果该文件保存为扩展名为.cpp的文件,则RStudio将调用正确的功能:sourceCpp()