簡體   English   中英

加載Rcpp並運行示例代碼

[英]Loading Rcpp and Running Sample Code

我對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,它也不會顯示為選項。

你忽略了這個:

Warning: cannot remove prior installation of package ‘Rcpp’

停止所有R會話。 開始一個新的,不要加載Rcpp,然后嘗試安裝/升級它。

您使用的操作系統有點受限,因為您無法刪除正在使用的共享庫。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM