I have a dataset with specified number of records per person:
set.seed(99)
# Create values from a Poisson distribution
freqs <- rpois(100, 3)
# Add an ID to each row
freqs <- as.data.frame(freqs)
freqs$id <- seq_len(nrow(freqs))
I now want the value in the freqs$freqs
to be the number of observations per each ID. The transformation would look like:
ID freqs
1 3
2 1
... ...
3 2
Ending up with:
ID freqs
1 3
1 3
1 3
2 1
... ....
3 2
3 2