Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
We at STATWORX work a lot with R and we often use the same little helper functions within our projects. These functions ease our daily work life by reducing repetitive code parts or by creating overviews of our projects. At first, there was no plan to make a package, but soon I realised, that it will be much easier to share and improve those functions, if they are within a package. Up till the 24th December I will present one function each day from helfRlein
. So, on the 20th day of Christmas my true love gave to me…
What can it do?
This little helper replaces non-standard characters (such as the German umlaut “ä”) with their standard equivalents (in this case “ae”). It is also possible to force all characters to lower case, trim whitespaces or replace whitespaces and dashes with underscores.
How to use it?
Let's look at a small example with different settings:
x <- " Élizàldë-González Strasse" char_replace(x, to_lower = TRUE) [1] "elizalde-gonzalez strasse" char_replace(x, to_lower = TRUE, to_underscore = TRUE) [1] "elizalde_gonzalez_strasse" char_replace(x, to_lower = FALSE, rm_space = TRUE, rm_dash = TRUE) [1] "ElizaldeGonzalezStrasse"
Overview
To see all the other functions you can either check out our GitHub or you can read about them here.
Have a merry advent season!
ABOUT US
STATWORX
is a consulting company for data science, statistics, machine learning and artificial intelligence located in Frankfurt, Zurich and Vienna. Sign up for our NEWSLETTER and receive reads and treats from the world of data science and AI.
Der Beitrag Day 20 – little helper char_replace erschien zuerst auf STATWORX.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.