title: How to reverse a string in R
body: <p>I'm trying to teach myself R and in doing some sample problems I came across the need to reverse a string.</p>
  <p>Here's what I've tried so far but the paste operation doesn't seem to have any effect.</p>
  <p>There must be something I'm not understanding about lists?  (I also don't understand why I need the [[1]] after strsplit.)</p>
  <pre class="lang-r prettyprint-override"><code>test &lt;- strsplit(&quot;greg&quot;, NULL)[[1]]
  test
  # [1] &quot;g&quot; &quot;r&quot; &quot;e&quot; &quot;g&quot;
  
  test_rev &lt;- rev(test)
  test_rev
  # [1] &quot;g&quot; &quot;e&quot; &quot;r&quot; &quot;g&quot;
  
  paste(test_rev)
  # [1] &quot;g&quot; &quot;e&quot; &quot;r&quot; &quot;g&quot;
  </code></pre>