Count of unique values across all columns in a data frame
<p>We have a data frame as below : </p>

<pre><code>raw&lt;-data.frame(v1=c("A","B","C","D"),v2=c(NA,"B","C","A"),v3=c(NA,"A",NA,"D"),v4=c(NA,"D",NA,NA))
</code></pre>

<p>I need a result data frame in the following format : </p>

<pre><code>result&lt;-data.frame(v1=c("A","B","C","D"), v2=c(3,2,2,3))
</code></pre>

<p>Used the following code to get the count across one particular column :</p>

<pre><code>count_raw&lt;-sqldf("SELECT DISTINCT(v1) AS V1, COUNT(v1) AS count FROM raw GROUP BY v1")
</code></pre>

<p>This would return count of unique values across an individual column. </p>

<p>Any help would be highly appreciated.</p>