我有一系列向量,我将其添加到DataFrame对象中以返回到R. 当我尝试添加一个包含长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&amp;,Rcpp :: traits :: false_type)中[用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&amp;,Rcpp :: traits :: false_type)[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&amp;,Rcpp :: traits :: false_type)[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&amp;,Rcpp: :traits :: false_type)[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&amp;,Rcpp :: traits :: wrap_type_unknown_tag)实例化[带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&amp;)实例化[与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&amp;)实例化[与U = Rcpp :: traits :: named_object&gt;,int RTYPE = 19,Rcpp :: traits :: true_type = Rcpp :: traits :: integral_constant,Rcpp :: Vector :: iterator = Rcpp :: internal :: Proxy_Iterator&gt ;, 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&amp;)[with U = Rcpp :: traits :: named_object&gt;,int RTYPE = 19,Rcpp :: Vector :: iterator = Rcpp :: internal :: Proxy_Iterator&gt;, 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&amp;,const T2&amp;,const T3&amp;,const T4&amp;,const T5&amp;,const T6&amp;)[with T1 = Rcpp :: traits :: named_object&gt ;, T2 = Rcpp :: tra its :: named_object&gt;,T3 = Rcpp :: traits :: named_object&gt;,T4 = Rcpp :: traits :: named_object&gt ;, T5 = Rcpp :: traits :: named_object&gt ;, T6 = Rcpp :: traits: :named_object&gt;,int RTYPE = 19,Rcpp :: Vector = Rcpp :: Vector&lt; 19&gt ;, Rcpp :: traits :: true_type = Rcpp :: traits :: integral_constant]'C:/R/R-3.0.1 /library/Rcpp/include/Rcpp/generated/Vector__create.h:288:37:从'static Rcpp :: Vector Rcpp :: Vector :: create实例化(const T1&amp;,const T2&amp;,const T3&amp;,const T4&amp; ,const T5&amp;,const T6&amp;)[T1 = Rcpp :: traits :: named_object&gt;,T2 = Rcpp :: traits :: named_object&gt ;,T3 = Rcpp :: traits :: named_object&gt ;, T4 = Rcpp :: traits :: named_object&gt;,T5 = Rcpp :: traits :: named_object&gt;,T6 = Rcpp :: traits :: named_object&gt;,int RTYPE = 19,Rcpp :: Vector = Rcpp :: Vector&lt; 19&gt; ]'C:/R/R-3.0.1/library/Rcpp/include/Rcpp/generated/DataFrame_generated.h:59:73:从'static Rcpp :: DataFrame Rcpp :: DataFrame :: create实例化(const T1&amp; ,const T2&amp;,const T3&amp;,co nst T4&amp;,const T5&amp;,const T6&amp;)[T1 = Rcpp :: traits :: named_object&gt;,T2 = Rcpp :: traits :: named_object&gt ;,T3 = Rcpp :: traits :: named_object&gt;, T4 = Rcpp :: traits :: named_object&gt;,T5 = Rcpp :: traits :: named_object&gt;,T6 = Rcpp :: traits :: named_object&gt;,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] make: * [quotes.o]错误1。
有没有办法将这种类型的矢量添加到DataFrame中?
答案 0 :(得分:6)
遗憾的是,由于CRAN不允许长时间使用C标准。
此外,R本身只有数字(又称双精度)和整数。所以我建议你只使用double作为一种类型。