我想知道是否有某种方法可以“重新打包”Rcpp返回的函数,以便在python代码块中使用。你知道吗
在附加的(玩具)示例中,我想重用“Npi”函数。换言之,我希望能够取消对该行的评论:
## threePi = Npi(3)
并让python代码运行Rcpp返回给R的重新打包版本的“Npi”。你知道吗
谢谢。你知道吗
——迈克
```{Rcpp defineFn}
#include <Rcpp.h>
// [[Rcpp::plugins(cpp11)]]
// [[Rcpp::export]]
double Npi(const int N) {
return (double(N)) * 3.14;
}
```{r useFnR}
print("This is from R")
twoPi <- Npi(2L)
print(twoPi)
```
```{python useFnPy, eval=TRUE}
sourceMsg = "This is from Python"
print(sourceMsg)
## threePi = Npi(3)
threePi = 3 * 3.14 # just to let the code render
print(threePi)
```
目前没有回答
相关问题 更多 >
编程相关推荐