加载Rcpp并运行示例代码

 但须g婚后 发布于 2022-12-23 11:43

我对R很新,我遇到了Rcpp的问题.从这个URL http://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:\Users\Ron\AppData\Local\Temp\RtmpE3jrvo\downloaded_packages 

Error in library(Rcpp) : there is no package called ‘Rcpp’

如果我尝试使用UI并选择加载Rcpp,它也不会显示为选项.

撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有