I have a data frame with one column. There are 10 rows.
(4.0 * 3.0)
(4.0 * 3.0)
(2.0 * (1.0 * (1.0 * 6.0)))
(4.0 * (3.0 * 1.0))
(6.0 * 2.0)
(6.0 * 2.0)
(2.0 * 6.0)
(2.0 * 6.0)
(2.0 * 6.0)
(6.0 * 2.0)
I need to extract the unique values in the column and the number of times it occurs. Using sqldf package I was able to get the unique values. But not the count.
Query:
sqldf("SELECT V1, COUNT(DISTINCT V1) as DinctC from dataset GROUP BY V1")
Output:
V1 DinctC
1 (2.0 * (1.0 * (1.0 * 6.0))) 1
2 (2.0 * 6.0) 1
3 (4.0 * (3.0 * 1.0)) 1
4 (4.0 * 3.0) 1
5 (6.0 * 2.0) 1
What I want is:
V1 DinctC
1 (2.0 * (1.0 * (1.0 * 6.0))) 1
2 (2.0 * 6.0) 3
3 (4.0 * (3.0 * 1.0)) 1
4 (4.0 * 3.0) 2
5 (6.0 * 2.0) 3
Edit: As Tim Biegeleisen pointed out "Distinct" is not a function therefore no need of the brackets. So updating DISTINCT(V1) to DISTINCT V1