1 #include <Rcpp.h> 2 using namespace Rcpp; 3 str_tolower(std::string str)4std::string str_tolower(std::string str){ 5 unsigned int input_size = str.size(); 6 for(unsigned int i = 0; i < input_size; i++){ 7 str[i] = tolower(str[i]); 8 } 9 return str; 10 } 11 12 //[[Rcpp::export]] pystr_capitalize_(CharacterVector strs)13CharacterVector pystr_capitalize_(CharacterVector strs){ 14 15 unsigned int input_size = strs.size(); 16 unsigned int individual_size; 17 std::string holding; 18 19 for(unsigned int i = 0; i < input_size; i++){ 20 individual_size = strs[i].size(); 21 if(individual_size > 0 && strs[i] != NA_STRING){ 22 holding = Rcpp::as<std::string>(strs[i]); 23 holding = str_tolower(holding); 24 holding[0] = toupper(holding[0]); 25 strs[i] = holding; 26 } 27 } 28 return strs; 29 } 30