Lin - 10 months ago 45

R Question

I wanted to create a vector of counts if possible.

For example: I have a vector

`x <- c(3, 0, 2, 0, 0)`

How can I create a frequency vector for all integers between 0 and 3? Ideally I wanted to get a vector like this:

`> 3 0 1 1`

which gives me the counts of 0, 1, 2, and 3 respectively.

Much appreciated!

Source (Stackoverflow)