[Rcpp-devel] vector<string> -> SEXP

Romain François francoisromain at free.fr
Tue Nov 10 13:46:24 CET 2009


On 11/10/2009 01:34 PM, Dirk Eddelbuettel wrote:
>
> On 10 November 2009 at 13:03, Romain François wrote:
> | On 11/10/2009 12:21 PM, Dirk Eddelbuettel wrote:
> |>
> |>  On 10 November 2009 at 09:38, Romain François wrote:
> |>  | On 11/09/2009 09:18 PM, Dirk Eddelbuettel wrote:
> |>  |>
> |>  |>   On 9 November 2009 at 21:02, Romain François wrote:
> |>  |>   | I see, thanks. I still think it might be valuable to factor it out as
> |>  |>   | maybe a static method of RstringVector. Something like :
> |>  |>   |
> |>  |>   | static SEXP convertToSEXP( std::vector<std::string>    v) ;
> |>  |>
> |>  |>   Oh, I see.
> |>  |>
> |>  |>   To eventually have a whole set of helper that convert from STL types to SEXPs
> |>  |>   and back?  That would be useful.
> |>  |
> |>  | Yes. In that case, I'll gradually add them as I need them in RProtoBuf.
> |>  | The question remains of where. Should I create a separate helper class
> |>  | that only has static methods
> |>
> |>  Or even just helper functions...
> |
> | Deal.
>
> Another thing is that Samperi, after having abandonded his code for
> thirty-five months [ during which I picked up Rcpp and made a few releases ]
> has just last week come out with RcppTemplate 6.0 and 6.1.

Seen this an was a bit confused. I suppose he knows you released a few 
versions.

Again, joining forces would be good, although his new incantation 
depends on zoo, so that means that for example RProtoBuf would 
indirectly depends on zoo which, I don't really like that (although 
don't really care since zoo seems well maintained).


> It's a rewrite, and he added a class RcppSEXP -- I haven't looked closely but
> I think that comes close to what you had in mind: from 'anything' to SEXP:
>
>
> // Return value from getSEXP(type) functions.
> class RcppSEXP {
> public:
>      SEXP sexp;
>      int numProtected;
>      RcppSEXP(SEXP sexp_, int numProtected_)
> 	: sexp(sexp_), numProtected(numProtected_) {}
>      RcppSEXP() : sexp(R_NilValue), numProtected(0) {}
> };
>
> and
>
> RcppSEXP getSEXP(double);
> RcppSEXP getSEXP(int);
> RcppSEXP getSEXP(std::string);
> RcppSEXP getSEXP(double *, int);
> RcppSEXP getSEXP(int *, int);
> RcppSEXP getSEXP(double **, int, int);
> RcppSEXP getSEXP(int **, int, int);
> RcppSEXP getSEXP(RcppDateTime&);
> RcppSEXP getSEXP(RcppDate&);
> RcppSEXP getSEXP(RcppFrame&);
> RcppSEXP getSEXP(RcppZoo&);
> RcppSEXP getSEXP(RcppFactor&);
>
> RcppSEXP getSEXP(std::vector<std::vector<double>  >&);
> RcppSEXP getSEXP(std::vector<std::vector<int>  >&);
> RcppSEXP getSEXP(RcppMatrix<int>&);
> RcppSEXP getSEXP(RcppMatrix<double>&);
> RcppSEXP getSEXP(RcppStringVector&);
> RcppSEXP getSEXP(std::vector<std::string>&);
>
> // These operations are redundant because they can be accomplished
> // using the template function below. Should deprecate.
> RcppSEXP getSEXP(RcppDateVector&);
> RcppSEXP getSEXP(RcppDateTimeVector&);
> RcppSEXP getSEXP(std::vector<double>&);
> RcppSEXP getSEXP(std::vector<int>&);
> RcppSEXP getSEXP(RcppVector<int>&);
> RcppSEXP getSEXP(RcppVector<double>&);
>
> It may be a bit more work to get these into Rcpp, but could be worth it.
>
> Dirk
>


-- 
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://tr.im/EAD5 : LondonR slides
|- http://tr.im/BcPw : celebrating R commit #50000
`- http://tr.im/ztCu : RGG #158:161: examples of package IDPmisc



More information about the Rcpp-devel mailing list