<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/day-11-little-helper-trim/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://www.statworx.com/de/blog/day-11-little-helper-trim/"> r-bloggers – STATWORX</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>We at <a rel="nofollow" href="https://www.statworx.com/" target="_blank">STATWORX</a> 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 <a rel="nofollow" href="https://github.com/STATWORX/helfRlein" target="_blank"><code>helfRlein</code></a>. So, on the 11th day of Christmas my true love gave to me…</p>
<p><img alt="door-11-trim" src="https://i1.wp.com/www.statworx.com/wp-content/uploads/door-11-trim.png?w=450&ssl=1" class="wp-image-16305" data-recalc-dims="1"></p>
<h2>What can it do?</h2>
<p>This little helper removes leading and trailing whitespaces from a string. With <a rel="nofollow" href="https://cran.r-project.org/doc/manuals/r-release/NEWS.pdf" target="_blank">R version 3.5.1</a> <code>trimws</code> was introduced, which does the exact same thing. This just shows, it was not a bad idea to write such a function. <img alt="😉" src="https://s.w.org/images/core/emoji/2.4/72x72/1f609.png" class="wp-smiley"></p>
<h2>How to use it?</h2>
<pre><code>x &lt;- c(&quot;  Hello world!&quot;, &quot;  Hello world! &quot;, &quot;Hello world! &quot;)
trim(x, lead = TRUE, trail = TRUE)
</code></pre>
<pre><code lang="r">[1] &quot;Hello world!&quot; &quot;Hello world!&quot; &quot;Hello world!&quot;
</code></pre>
<p>The <code>lead</code> and <code>trail</code> parameters indicates if only leading, trailing or both whitspaces should be removed.</p>
<h2>Overview</h2>
<p>To see all the other functions you can either check out our <a rel="nofollow" href="https://github.com/STATWORX/helfRlein" target="_blank">GitHub</a> or you can read about them <a rel="nofollow" href="https://www.statworx.com/tag/helfrlein/" target="_blank">here</a>.</p>
<p>Have a merry advent season!</p>
<div>
<h6>Über den Autor</h6>
<p><img src="https://i1.wp.com/www.statworx.com/wp-content/uploads/jakob-1-300x300.jpg?resize=180%2C180&ssl=1" width="180" alt="Jakob Gepp" class="wp-user-avatar wp-user-avatar-180" data-recalc-dims="1" height="180"></p>
<div>
<h4>Jakob Gepp</h4>
<p>Numbers were always my passion and as a data scientist and statistician at <a rel="nofollow" href="https://www.statworx.com/" target="_blank">STATWORX</a> I can fullfill my nerdy needs. Also I am responsable for our blog. So if you have any questions or suggestions, just send me an email!</p>
</div>
</div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<h1>ABOUT US</h1>
</div>
</div>
</div>
<hr>
<div>
<p><span><span>STATWORX</span><br></span><span>is a consulting company for data science, statistics, machine learning and artificial intelligence </span><span>located in Frankfurt, Zurich and Vienna. Sign up for our NEWSLETTER and receive reads and treats from the world of data science and AI.</span> </p>
</div>
<p><a data-x-toggle="1" tabindex="0" data-x-toggleable="e15819-7">
<p> <span>
<p><span>
<p><i data-x-icon-o=""></i></p>
<p> <span><span>Sign Up Now!</span></span> </p></span>
<p>




<p>Der Beitrag <a rel="nofollow" href="https://www.statworx.com/de/blog/day-11-little-helper-trim/" target="_blank">Day 11 – little helper trim</a> erschien zuerst auf <a rel="nofollow" href="https://www.statworx.com/de/" target="_blank">STATWORX</a>.</p>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://www.statworx.com/de/blog/day-11-little-helper-trim/"> r-bloggers – STATWORX</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/nptAxeE67c8" height="1"></a></div></span></a></div></div></div></div>