This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <Rcpp.h> | |
| using namespace Rcpp; | |
| // [[Rcpp::export]] | |
| StringVector check( StringVector x ) { | |
| Rcout << "The type of x is: " << ::TYPEOF( x ) << std::endl; | |
| Rcout << "The type of x(0) is: " << ::TYPEOF( x(0) ) << std::endl; | |
| Rcout << "The integer associated with STRSXPs is: " << STRSXP << std::endl; | |
| Rcout << "The integer associated with CHARSXPs is: " << CHARSXP << std::endl; | |
| Rcout << "Is x a string?: " << ::Rf_isString(x) << std::endl; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| title: Using Boost's foreach macro | |
| author: Kevin Ushey | |
| license: GPL (>= 2) | |
| tags: basics boost | |
| summary: Boost's BOOST_FOREACH can enable a more functional programming style. | |
| --- | |
| Boost provides a macro, `BOOST_FOREACH`, that allows us to easily iterate | |
| over elements in a container, similar to what we might |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| title: Make your own 'apply' functions for matrices | |
| author: Kevin Ushey | |
| license: GPL (>= 2) | |
| tags: Rcpp apply matrix | |
| summary: Clever use of sourceCpp can allow you to define your own 'apply' functions on the fly. | |
| --- | |
| Make your own 'apply' functions | |
| ========== |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // the column-wise implementation is just as fast as colMeans, | |
| // but the row-wise operation is not quite as fast as rowMeans. | |
| // can I do better? | |
| #include <Rcpp.h> | |
| using namespace Rcpp; | |
| template <class T> | |
| inline double do_mean( T& x ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| title: Handling Strings with Rcpp | |
| author: Kevin Ushey | |
| license: GPL (>= 2) | |
| tags: string vector | |
| summary: Demonstrates how one might handle a vector of strings with `Rcpp`, | |
| in addition to returning output. | |
| --- | |
| This is a quick example of how you might use Rcpp to send and receive R |
NewerOlder