Skip to content

Instantly share code, notes, and snippets.

@nathan-russell
Created April 4, 2017 11:00
Show Gist options
  • Save nathan-russell/a8395e1ca8b9ea4a57b5dedb95b833d2 to your computer and use it in GitHub Desktop.
Save nathan-russell/a8395e1ca8b9ea4a57b5dedb95b833d2 to your computer and use it in GitHub Desktop.
#include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::export]]
CharacterVector ModifyString(CharacterVector x)
{
String ref = x[0];
ref = "Modified";
return x;
}
// [[Rcpp::export]]
CharacterVector ModifyProxy(CharacterVector x)
{
internal::string_proxy<STRSXP> ref = x[0];
ref = "Modified";
return x;
}
/*** R
x <- letters[1:5]
ModifyString(x)
# [1] "a" "b" "c" "d" "e"
ModifyProxy(x)
# [1] "Modified" "b" "c" "d" "e"
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment