加载Rcpp和运行示例代码 [英] Loading Rcpp and Running Sample Code

查看:316
本文介绍了加载Rcpp和运行示例代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是R的新手,我有一个问题与Rcpp。从此网址 http:/ /www.r-bloggers.com/installing-rcpp-on-windows-7-for-r-and-c-integration/ 我已按照安装Rcpp的所有步骤。我还安装和加载RcppClassic和Rinside。当我尝试运行代码建议:

I am fairly new to R and am having an issue with Rcpp. From this URL http://www.r-bloggers.com/installing-rcpp-on-windows-7-for-r-and-c-integration/ I have followed all steps for installing Rcpp. I also installed and loaded RcppClassic and Rinside. When I try to run the code suggested:

# 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

It is also very odd that if I try to use the UI and select to load Rcpp, it does not appear as an option.

推荐答案

您忽略了这一点:

Warning: cannot remove prior installation of package ‘Rcpp’

停止所有R会话。开始一个新的,不加载Rcpp,然后尝试安装/升级它。

Stop all R sessions. Start a fresh one, do not load Rcpp, then try to install / upgrade it.

您使用的操作系统有限,您无法移除正在使用的共享库。

The OS you use is a little limited in that you cannot remove shared libraries that are in use.

这篇关于加载Rcpp和运行示例代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆