Learn R Programming

RcppExamples (version 0.1.10)

RcppStringVectorExample: Example of using Rcpp StringVector (aka CharacterVector)

Description

The StringVector (aka CharacterVector) class represents character vectors.

Arguments

Author

Dominick Samperi wrote the initial versions of Rcpp (and RcppTemplate) during 2005 and 2006. Dirk Eddelbuettel made some additions, and became maintainer in 2008. Dirk Eddelbuettel and Romain Francois have been extending Rcpp since 2009.

Details

The C++ code presented in the StringVectorExample.cpp file:


        #include <Rcpp.h>
        using namespace Rcpp ;
        
        // [[Rcpp::export]]
        List StringVectorExample(const StringVector & orig) {
            StringVector vec(orig.size());	
        
            std::transform(orig.begin(), orig.end(), vec.begin(), 
        		   make_string_transformer(tolower));
        
            return List::create(Named("result")   = vec,
                                Named("original") = orig);
        }

References

Writing R Extensions, available at https://www.r-project.org.

Examples

Run this code
  RcppStringVectorExample(c("Tick", "Tack", "Tock"))

Run the code above in your browser using DataLab