加载Rcpp并运行示例代码
Loading Rcpp and Running Sample Code
我对R相当陌生,并且对Rcpp有问题。从此URLhttp://www.r-bloggers.com/installing-rcpp-on-windows-7-for-r-and-c-integration/我已经遵循了安装Rcpp的所有步骤。我还安装并加载了RcppClassic和Rinside。当我尝试运行建议的代码时:
# install packages
install.packages(c("Rcpp", "rbenchmark", "inline", "Runit"))
# load main two packages
library(Rcpp)
library(inline)
# do something with Rcpp to quickly check that it works
body <- '
NumericVector xx(x);
return wrap( std::accumulate( xx.begin(), xx.end(), 0.0));'
add <- cxxfunction(signature(x = "numeric"), body, plugin = "Rcpp")
x <- 1
y <- 2
res <- add(c(x, y))
res
#[1] 3
我收到以下消息:
package ‘Rcpp’ successfully unpacked and MD5 sums checked
Warning: cannot remove prior installation of package ‘Rcpp’ package
‘rbenchmark’ successfully unpacked and MD5 sums checked package
‘inline’ successfully unpacked and MD5 sums checked
package ‘RUnit’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:UsersRonAppDataLocalTempRtmpE3jrvodownloaded_packages
Error in library(Rcpp) : there is no package called ‘Rcpp’
同样奇怪的是,如果我尝试使用UI并选择加载Rcpp,它不会显示为一个选项。
您忽略了这一点:
Warning: cannot remove prior installation of package ‘Rcpp’
停止所有R会话。启动一个新的,不要加载Rcpp,然后尝试安装/升级它。
您使用的操作系统有点受限,因为您无法删除正在使用的共享库。
相关文章:
- 我的代码运行良好,但在游戏循环中中断
- 通过窗口从C++代码运行 WSL 命令
- 如何使用 lldb 查找我的代码运行的位置
- 无法在 VS Code 上使用代码运行程序运行C++文件
- 我的代码运行良好,但现在当尝试将其制作成模板时,我遇到了许多看似无关的错误。这是怎么回事?
- Visual Studio代码运行环境
- 如何从C++代码运行自定义 GPU tensorflow::op?
- 在 ZeroMQ 中绑定订阅者套接字并连接发布者套接字会在代码运行时给出错误.为什么
- 代码运行缓慢
- .NET CORE 2 DLL引用带有C 代码运行时错误
- C++ 中控制台代码运行时的分段错误
- C++ 菜单代码 - 运行另一个类
- 以下代码运行后,如何在程序再次运行之前清除用户声明的变量 empName
- 当我使用此合并排序代码运行时,输出错误
- 有哪些优化技巧可以使我的代码运行得更快
- 使 C 代码能够作为C++代码运行
- 错误代码LNK1561阻止我的代码运行
- 如果我用代码块编译代码,为什么我的代码运行速度更快
- 更改Linux用户从C/C 代码运行时间
- 为什么这段代码运行这么慢