Wednesday, 21 August 2013

How to find unique field values from column in data frame R

How to find unique field values from column in data frame R

I have data frame which has column that is CustomerID. In this i want to
create new two columns of unique Quarter and CustomerID which satisfies
the conditions like.
For eg:
Quarter CustomerID
2009 Q1 1234
2009 Q2 1324
2009 Q1 1234
2009 Q3 8764
2009 Q4 5432
What i want is:
Quarter CustomerID FilterQuarter UniqueCustomerID
2009 Q1 1234 2009 Q1 1234
2009 Q2 1324 2009 Q2 1324
2009 Q1 1234 2009 Q3 8764
2009 Q3 8764 2009 Q4 5432
2009 Q4 5432
How to do this in R. I tried unique function but it is not working as i want

No comments:

Post a Comment