Hi Tal,
```
cppFunction('
std::vector<RObject> temp2_fail(RObject x){
std::vector<RObject> lower;
List x_list(wrap(x));
int n = x_list.size();
lower.push_back(x);
return(lower) ;
}
')
```
Is this what you want?
2013/8/20 Tal Galili <[email protected]>
> Dear list members,
>
> I would like to be able to get an element pushed with its attributes, and
> I came across the following problem:
>
> cppFunction('
> std::vector<List> temp(List x){
> std::vector<List> lower;
> lower.push_back(x);
> return(lower) ;
> }
> ')
> x = list(structure(1L, animal = "cat"))
> temp(x)
> temp(x[1])
> temp(x[[1]]) # is there a way to not make this output without attributes?
>
>
>
> If I use RObject, it will solve it, but then I would later not be able to
> iterate over the object, because I can't seem to get the .size() of an
> RObject.
>
> Here is the code with the RObject:
>
>
> cppFunction('
> std::vector<RObject> temp2(RObject x){
> std::vector<RObject> lower;
> lower.push_back(x);
> return(lower) ;
> }
> ')
> x = list(structure(1L, animal = "cat"))
> temp2(x)
> temp2(x[1])
> temp2(x[[1]]) # Now it works as I want, but the following wouldn't work:
>
>
>
>
> cppFunction('
> std::vector<RObject> temp2_fail(RObject x){
> std::vector<RObject> lower;
> int n x.size();
> lower.push_back(x);
> return(lower) ;
> }
> ')
>
>
>
> Any ideas?
>
>
>
>
> ----------------Contact
> Details:-------------------------------------------------------
> Contact me: [email protected] |
> Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
> www.r-statistics.com (English)
>
> ----------------------------------------------------------------------------------------------
>
>
> _______________________________________________
> Rcpp-devel mailing list
> [email protected]
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
>
_______________________________________________
Rcpp-devel mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel