【发布时间】:2021-02-24 21:20:09
【问题描述】:
今天我更新到 R 4.0.4 并且 Rcpp::match 不能正常工作。我认为版本更新是原因,但不确定。任何建议都很棒。 (编辑:我刚刚在 R 3.6.3 中尝试过,以下代码运行良好)
(EDIT v2:将 Rstudio 更新到最新版本解决了这个问题)
下面是test_RcppMatch.cpp
#include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::export]]
Rcpp::IntegerVector test(Rcpp::CharacterVector SampleInModel,
Rcpp::CharacterVector SampleInPlink)
{
Rcpp::IntegerVector posSampleInPlink = Rcpp::match(SampleInModel, SampleInPlink);
return posSampleInPlink;
}
// You can include R code blocks in C++ files processed with sourceCpp
// (useful for testing and development). The R code will be automatically
// run after the compilation.
//
/*** R
test(c(1,3,5,7,9),1:10)
*/
以下是错误信息
> Rcpp::sourceCpp('C:/Users/wenji/OneDrive/Desktop/test_RcppMatch.cpp')
> test(c(1,3,5,7,9),1:10)
Error in test(c(1, 3, 5, 7, 9), 1:10) :
SET_VECTOR_ELT() can only be applied to a 'list', not a 'symbol'
下面是我的平台
> sessionInfo()
R version 4.0.4 (2021-02-15)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19041)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods
[7] base
other attached packages:
[1] Rcpp_1.0.6 GRAB_0.0.1
loaded via a namespace (and not attached):
[1] compiler_4.0.4 tools_4.0.4 data.table_1.14.0
[4] packrat_0.5.0
【问题讨论】:
标签: rcpp