title: How do I rearrange values in different columns in an R dataframe
body: <p>I have a dataframe of customer data. It has 3 columns for phone numbers.
  Something similar to the below table:</p>
  <pre><code>x &lt;- data.frame(&quot;Phone1&quot; = c(123,&quot;NULL&quot;,245), &quot;Phone2&quot; = c(&quot;NULL&quot;,&quot;NULL&quot;,325 ), &quot;Phone3&quot; = c(847,219,&quot;NULL&quot;))
  &gt; View(x)
  &gt; x
    Phone1 Phone2 Phone3
  1    123   NULL    847
  2   NULL   NULL    219
  3    245    325   NULL
  </code></pre>
  <p>Now , I want to rearrange the values in these columns such that the NON-NULL values come first, and the NULL values of each record are pushed to the last. This is how I want my output to be:</p>
  <pre><code>Phone1 Phone2 Phone3
  1    123    847   NULL
  2    219   NULL   NULL
  3    245    325   NULL
  </code></pre>
  <p>I tried doing this with a series of if statements, but it takes a lot of time, since my original dataframe has a lot of records. I was wondering if there is a simpler method using dplyr or other packages that can help with this.</p>