2

我有一系列向量,我将它们添加到 DataFrame 对象中以返回到 R。当我尝试添加具有 long long 元素的向量时,问题就出现了。

// [[Rcpp::export]]
DataFrame test()
{
std::vector<long long> x;
return DataFrame::create(Named("x") = x);
}

返回的错误是

g++ -m64 -I"C:/R/R-30~1.1/include" -DNDEBUG -I"C:/R/R-3.0.1/library/Rcpp/include" -I"d:/RCompile/CRANpkg /extralibs64/local/include" -O2 -Wall -mtune=core2 -c quotes.cpp -o quotes.o 在来自 C:/R/R-3.0.1/library/Rcpp/include/RcppCommon.h 的文件中: 117:0,来自 C:/R/R-3.0.1/library/Rcpp/include/Rcpp.h:27,来自quotes.cpp:1: C:/R/R-3.0.1/library/Rcpp/ include/Rcpp/internal/wrap.h: 在函数'SEXPREC* Rcpp::internal::wrap_dispatch_unknown_iterable(const T&, Rcpp::traits::false_type) [with T = long long int, SEXP = SEXPREC*, Rcpp:: traits::false_type = Rcpp::traits::integral_constant]': C:/R/R-3.0.1/library/Rcpp/include/Rcpp/internal/wrap.h:691:98: 从 'SEXPREC* Rcpp 实例化::internal::wrap_dispatch_unknown(const T&, Rcpp::traits::false_type) [with T = long long int, SEXP = SEXPREC*, Rcpp::traits::false_type = Rcpp::traits::integral_constant]' C:/R/R-3.0.1/library/Rcpp/include/Rcpp /internal/wrap.h:723:96: 从 'SEXPREC* Rcpp::internal::wrap_dispatch_eigen(const T&, Rcpp::traits::false_type) [with T = long long int, SEXP = SEXPREC*, Rcpp: :traits::false_type = Rcpp::traits::integral_constant]' C:/R/R-3.0.1/library/Rcpp/include/Rcpp/internal/wrap.h:740:80: 从 'SEXPREC* Rcpp 实例化::internal::wrap_dispatch_unknown_importable(const T&, Rcpp::traits::false_type) [with T = long long int, SEXP = SEXPREC*, Rcpp::traits::false_type = Rcpp::traits::integral_constant]' C: /R/R-3.0.1/library/Rcpp/include/Rcpp/internal/wrap.h:760:99: 从 'SEXPREC* Rcpp::internal::wrap_dispatch(const T&, Rcpp::traits::wrap_type_unknown_tag) [with T = long long int, SEXP = SEXPREC*]' C:/R/R-3.0.1/library/Rcpp/include/Rcpp/internal/wrap.h:863:104: 从 'SEXPREC* 实例化Rcpp::wrap(const T&) [with T = long long int, SEXP = SEXPREC*]' C:/R/R-3.0.1/library/Rcpp/include/Rcpp/internal/wrap.h:193:3 : [跳过 14 个实例化上下文] C:/R/R-3.0.1/library/Rcpp/include/Rcpp/vector/Vector.h:395:9: 从 'static void Rcpp::Vector::replace_element__dispatch(Rcpp ::traits::true_type, Rcpp::Vector::iterator, SEXP, int, const U&) [with U = Rcpp::traits::named_object >, int RTYPE = 19, Rcpp::traits::true_type = Rcpp: :traits::integral_constant, Rcpp::Vector::iterator = Rcpp::internal::Proxy_Iterator >, SEXP = SEXPREC*]' C:/R/R-3.0.1/library/Rcpp/include/Rcpp/vector/ Vector.h:384:9: 从 ' 实例化static void Rcpp::Vector::replace_element(Rcpp::Vector::iterator, SEXP, int, const U&) [with U = Rcpp::traits::named_object >, int RTYPE = 19, Rcpp::Vector::iterator = Rcpp::internal::Proxy_Iterator >, SEXP = SEXPREC*]' C:/R/R-3.0.1/library/Rcpp/include/Rcpp/generated/Vector_create.h:318:2: 从 'static Rcpp::Vector Rcpp::Vector::create 实例化_dispatch(Rcpp::traits::true_type, const T1&, const T2&, const T3&, const T4&, const T5&, const T6&) [with T1 = Rcpp::traits::named_object >, T2 = Rcpp::traits::named_object >, T3 = Rcpp::traits::named_object >, T4 = Rcpp::traits::named_object >, T5 = Rcpp::traits::named_object >, T6 = Rcpp::traits::named_object >, int RTYPE = 19 , Rcpp::Vector = Rcpp::Vector<19>, Rcpp::traits::true_type = Rcpp::traits::integral_constant]' C:/R/R-3.0.1/library/Rcpp/include/Rcpp/生成/Vector__create.h:288:37: 从 'static Rcpp::Vector Rcpp::Vector::create(const T1&, const T2&, const T3&, const T4&, const T5&, const T6&) [with T1 = Rcpp: :traits::named_object >, T2 = Rcpp::traits::named_object >, T3 = Rcpp::traits::named_object >, T4 = Rcpp::traits::named_object >, T5 = Rcpp::traits::named_object >, T6 = Rcpp::traits::named_object >, int RTYPE = 19, Rcpp::Vector = Rcpp::Vector<19>]' C:/R/R -3.0.1/library/Rcpp/include/Rcpp/generated/DataFrame_generated.h:59:73: 实例化自 'static Rcpp::DataFrame Rcpp::DataFrame::create(const T1&, const T2&, const T3&, const T4& , const T5&, const T6&) [with T1 = Rcpp::traits::named_object >, T2 = Rcpp::traits::named_object >, T3 = Rcpp::traits::named_object >, T4 = Rcpp::traits:: named_object >, T5 = Rcpp::traits::named_object >, T6 = Rcpp::traits::named_object >, Rcpp::DataFrame = Rcpp::DataFrame]' quotes.cpp:58:26: 从这里实例化 C:/ R/R-3.0.1/library/Rcpp/include/Rcpp/internal/wrap.h:474:11:错误:从“long long int”到“SEXP”的无效转换[-fpermissive] 制作:* [quotes.o] 错误 1 ​​。

有没有办法将这种类型的向量添加到 DataFrame 中?

4

1 回答 1

6

遗憾的是,没有,因为 CRAN 只允许没有 long long 的 C 标准。

此外,R 本身只有数字(又名双精度)和整数。所以我建议你只使用 double 作为类型。

于 2013-07-09T23:53:34.077 回答