I do have R (and the magical Rcpp package), Rtools, and Rstudio installed on my ultrabook. I just realized how trivial it is to tweak C++ code fragments using these tools together.
For example, in order to run this very simple C++ code fragment:
===========================================
#include <iostream>
using std::cout;
int main() {
for (int hashNum = 1; hashNum <= 5; hashNum++) {
cout << "#";
}
cout << "\n";
return 0;
}
===========================================
One just need to add a few lines so that the code looks like this:
===========================================
#include <Rcpp.h>
using std::cout;
using namespace Rcpp;
// [[Rcpp::export]]
int main() {
for (int hashNum = 1; hashNum <= 5; hashNum++) {
cout << "#";
}
cout << "\n";
return 0;
}
/*** R
main()
*/
===========================================
Hit Ctrl + Enter, problem solved!
No comments:
Post a Comment