为什么这会使我的 R 会话中止?
Why does this make my R session abort?
我正在尝试在 Rcpp 中实现命名列表调用
在 R
b<-list("bgroups"=c(1,1,1,1,0,0,0,0))
> b$bgroups
[1] 1 1 1 1 0 0 0 0
cppFunction(
"
NumericVector split(Rcpp::List & b){
Rcpp::NumericVector c= b['bgroups'];
return c;
}")
split(b)
但这会导致我的 R 会话中止。
我正在尝试按照 Dirk 的一个演示文稿中的说明实施此过程,但我遗漏了一些东西。
This is an extension of my question
以下作品:
b<-list("bgroups"=c(1,1,1,1,0,0,0,0))
b$bgroups
#[1] 1 1 1 1 0 0 0 0
Rcpp::cppFunction(
'
NumericVector split(Rcpp::List & b){
Rcpp::NumericVector c = b["bgroups"];
return c;
}')
split(b)
#[1] 1 1 1 1 0 0 0 0
在C++中,'
用于引用字符,而"
用于引用字符串。我的编译器警告我:
warning: character constant too long for its type
Rcpp::NumericVector c= b['bgroups'];
^~~~~~~~~
通常认真对待编译器警告是个好主意。
我正在尝试在 Rcpp 中实现命名列表调用
在 R
b<-list("bgroups"=c(1,1,1,1,0,0,0,0))
> b$bgroups
[1] 1 1 1 1 0 0 0 0
cppFunction(
"
NumericVector split(Rcpp::List & b){
Rcpp::NumericVector c= b['bgroups'];
return c;
}")
split(b)
但这会导致我的 R 会话中止。
我正在尝试按照 Dirk 的一个演示文稿中的说明实施此过程,但我遗漏了一些东西。
This is an extension of my question
以下作品:
b<-list("bgroups"=c(1,1,1,1,0,0,0,0))
b$bgroups
#[1] 1 1 1 1 0 0 0 0
Rcpp::cppFunction(
'
NumericVector split(Rcpp::List & b){
Rcpp::NumericVector c = b["bgroups"];
return c;
}')
split(b)
#[1] 1 1 1 1 0 0 0 0
在C++中,'
用于引用字符,而"
用于引用字符串。我的编译器警告我:
warning: character constant too long for its type
Rcpp::NumericVector c= b['bgroups'];
^~~~~~~~~
通常认真对待编译器警告是个好主意。