title: Extract names and covert to email addresses in R
body: <p>I have the following string: "    John Andrew Thomas"(4 empty spaces before John) and I need to split and concat it so my output is "John@gmail.com;Andrew@gmail.com;Thomas@gmail.com", also I need to remove all whitespaces.</p>
  
  <p>My best guess is:</p>
  
  <pre><code>test = unlist(lapply(names, strsplit, split = " ", fixed = FALSE))
  paste(test, collapse = "@gmail.com")
  </code></pre>
  
  <p>but I get this as an output:</p>
  
  <pre><code>"@gmail.com@gmail.com@gmail.com@gmail.comJohn@gmail.comAndrew@gmail.comThomas"
  </code></pre>