Home > Blockchain >  In R, get a frequency distribution of IDs by count of distinct / unique categorical (factor) attribu
In R, get a frequency distribution of IDs by count of distinct / unique categorical (factor) attribu

Time:06-10

Background

I've got a dataframe df:

df <- data.frame(ID = c("a","a","a", "b", "c","c","c","c","d","d","d","d"),
                 manufacturer = c("ferrari","ferrari","porsche", "bugatti", "lamborghini","aston martin","lotus","koenigsegg","pagani","ford","mclaren","mercedes benz"),
                 stringsAsFactors=FALSE)

> df
   ID  manufacturer
1   a       ferrari
2   a       ferrari
3   a       porsche
4   b       bugatti
5   c   lamborghini
6   c  aston martin
7   c         lotus
8   c    koenigsegg
9   d        pagani
10  d          ford
11  d       mclaren
12  d mercedes benz

It's a little table of wealthy people (ID) and the manufacturers of supercars they own. Some nice rides in here

  • Related