title: How to skip a paste() argument when its value is NA in R
body: <p>I have a data frame with the columns <em>city, state, and country</em>. I want to create a string that concatenates: "City, State, Country". However, one of my cities doesn't have a State (has a <code>NA</code> instead). I want the string for that city to be "City, Country". Here is the code that creates the wrong string:</p>
  
  <pre><code># define City, State, Country
    city &lt;- c("Austin", "Knoxville", "Salk Lake City", "Prague")
    state &lt;- c("Texas", "Tennessee", "Utah", NA)
    country &lt;- c("United States", "United States", "United States", "Czech Rep")
  # create data frame
    dff &lt;- data.frame(city, state, country)
  # create full string
    dff["string"] &lt;- paste(city, state, country, sep=", ")
  </code></pre>
  
  <p>When I display <code>dff$string</code>, I get the following. Note that the last string has a <code>NA,</code>, which is not needed:</p>
  
  <pre><code>&gt; dff["string"]
                                 string
  1        Austin, Texas, United States
  2 Knoxville, Tennessee, United States
  3 Salk Lake City, Utah, United States
  4               Prague, NA, Czech Rep
  </code></pre>
  
  <p>What do I do to skip that <code>NA,</code>, including the <code>sep = ", "</code>.</p>