Apply and function a gsub in a lots of columns
<p>I am kind of new to R and I want to apply the <code>gsub</code> function in columns 6 to 12 in my data frame called <code>x</code>.  However, I am kind of stuck. I started using:</p>
<pre><code>gsub(&quot;\\.&quot;, &quot;&quot;,x[,c(6:12)])
</code></pre>
<p>But then it returned only a few rows.
Then, I tried to use this:</p>
<pre><code>x1&lt;-apply(x,c(6:12),function(x) gsub(&quot;\\.&quot;, &quot;&quot;,x))
</code></pre>
<p>But I got the following error:</p>
<pre><code>Error in if (d2 == 0L) { : missing value where TRUE/FALSE needed
</code></pre>
<p>Also tried this:</p>
<pre><code>for (i in x[,c(6:12)]) 
{a&lt;-data.frame(gsub(&quot;\\.&quot;, &quot;&quot;,i))}
</code></pre>
<p>Does anybody have a tip or a solution?
It would also be great if someone showed me how to use an <code>apply</code> function and <code>for</code>.</p>