<div dir="ltr">Hi all!<br>I've written a function that makes use of a python module called ftfy and made it available in R through Reticulate.<br>The aim is to fix broken encoding. The function is, unfortunately, a scalar function.<br>I attempted to vectorise the function. by means of a for loop, but the speed of this function is a real concern when the datasets get over 500 000 rows.<br><br>I've adapted the function to conditionally modify only broken text with ifelse statements.<br><br>I *really* want to speed up this function using Rcpp, but there are two problems<br><br>1. I tried researching how to call python functions from R through C++ scripts but none have been successful for me. ( <span class="gmail-muted" style="color:rgb(153,153,153);font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:13px">

<a href="https://gallery.rcpp.org/articles/rcpp-python/">https://gallery.rcpp.org/articles/rcpp-python/</a>   </span> )<br><br>2. I'm having trouble to modifying all elements of a StringVector using Rcpp<br><br>Any advice would be highly appreciated!<br><br>Attached are the vectorised function script, conditionally fixing broken encoding, and lastly, my *flawed* Rcpp script <br><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><font face="arial, helvetica, sans-serif"><b><br></b></font></div><font face="arial, helvetica, sans-serif"><b>Casper Crause</b></font><div><font face="arial, helvetica, sans-serif"><b><br></b></font></div><div><font face="arial, helvetica, sans-serif"><b>Cell:     072 475 8969</b></font></div><div><font face="arial, helvetica, sans-serif"><b>Email: <a href="mailto:ccrause07@gmail.com" target="_blank">ccrause07@gmail.com</a></b></font></div></div></div></div>