How to create a frequency table of a vector that contains repeated values in R?


We can do this by using table function with as.data.frame

Example

> X <- c(25, 34, 25, 47, 69, 69, 69, 23, 24, 25, 23, 21, 70, 34, 25, 47, 21, 23, 69, 69, 25, 64)
> as.data.frame(table(X))
  X Freq
1 21 2
2 23 3
3 24 1
4 25 5
5 34 2
6 47 2
7 64 1
8 69 5
9 70 1

Updated on: 06-Jul-2020

569 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements