title: How to insert comma between the numbers in R?
body: <p>I am trying to locate positions of a particular character within a long string and capture the positions as comma separated string. For example in the example below, I would like to get s3 value as <strong>3, 4, 10</strong> instead of <strong>"3"  "4"  "10"</strong>. Please advice.</p>
  
  <pre><code>s1 &lt;- "Hello.World"
  s2 &lt;- which(strsplit(s1, '')[[1]]=='l')
  s3 &lt;- gsub(" ",", ",as.character(s2))
  s3
  [1] "3"  "4"  "10"
  </code></pre>