我在Windows 7上使用R 2.15.1,当我运行以下R代码时收到错误消息。有人帮帮我吗?
> library(inline)
>
> if( require( Rcpp ) ){
+ fx <- cxxfunction( signature(x = "integer", y = "numeric" ) , '
+ return wrap( as<int>(x) * as<double>(y) ) ;
+ ', plugin = "Rcpp" )
+ }
Loading required package: Rcpp
cygwin warning:
MS-DOS style path detected: C:/R/R-215~1.1/etc/i386/Makeconf
Preferred POSIX equivalent is: /cygdrive/c/R/R-215~1.1/etc/i386/Makeconf
CYGWIN environment variable option "nodosfilewarning" turns off this warning.
Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
Syntax error: "(" unexpected (expecting "fi")
make: *** [file11a82c84184d.dll] Error 2
ERROR(s) during compilation: source code errors or compiler configuration errors!
Program source:
1:
2: // includes from the plugin
3:
4: #include <Rcpp.h>
5:
6:
7: #ifndef BEGIN_RCPP
8: #define BEGIN_RCPP
9: #endif
10:
11: #ifndef END_RCPP
12: #define END_RCPP
13: #endif
14:
15: using namespace Rcpp;
16:
17:
18: // user includes
19:
20:
21: // declarations
22: extern "C" {
23: SEXP file11a82c84184d( SEXP x, SEXP y) ;
24: }
25:
26: // definition
27:
28: SEXP file11a82c84184d( SEXP x, SEXP y ){
29: BEGIN_RCPP
30:
31: return wrap( as<int>(x) * as<double>(y) ) ;
32:
33: END_RCPP
34: }
35:
36:
Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! cygwin warning:
MS-DOS style path detected: C:/R/R-215~1.1/etc/i386/Makeconf
Preferred POSIX equivalent is: /cygdrive/c/R/R-215~1.1/etc/i386/Makeconf
CYGWIN environment variable option "nodosfilewarning" turns off this warning.
Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
Syntax error: "(" unexpected (expecting "fi")
make: *** [file11a82c84184d.dll] Error 2
In addition: Warning message:
running command 'C:/R/R-2.15.1/bin/i386/R CMD SHLIB file11a82c84184d.cpp 2> file11a82c84184d.cpp.err.txt' had status 1
>
答案 0 :(得分:2)
在Linux下工作(虽然我做了一些小改动/简化):
R> library(inline)
R> fx <- cxxfunction(signature(x = "integer", y = "numeric" ),
+ body = 'return wrap( as<int>(x) * as<double>(y) );',
+ plugin = "Rcpp" )
R> print(fx(2, 2.5))
R> [1] 5
R>
如果您将环境变量CYGWIN
设置为nodosfilewarning
,那么Windows上的线路噪音会稍微减少。