Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
String Slicer in C++
#include <Rcpp.h>
#include <iostream>
using namespace Rcpp;
using namespace std;
// [[Rcpp::export]]
std::string string_slicer( std::string input, std::vector< int > start, std::vector< int > end) {
std::string working_copy = input;
for(std::vector<int>::size_type i = start.size() - 1; i != (std::vector<int>::size_type) -1; i--) {
working_copy.erase(start[i]-1, (end[i] - start[i])+1);.
return working_copy;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment