How to Create Relative Frequency Tables in R
- R-PROGRAMMING
To create relative frequency tables in R, you can use two different ways prop.table() function and dplyr package.
The following methods show how you can do it with syntax.
Method 1: Use prop.table() Function
frequency_table <- table(data) prop.table(frequency_table) Method 2: Use dplyr Package
library(dplyr) df %>% group_by(data) %>% summarise(count = n()) %>% mutate(relative_frequency = count / sum(count)) The following examples show how to create relative frequency table in R.
Using prop.