# Frequency Distribution of Qualitative Data in R

• Last Updated : 16 Sep, 2022

The frequency table in R programming Language is used to create a table with a respective count for both the discrete values and the grouped intervals. It indicates the counts of each segment of the table. It is helpful for constructing the probabilities and drawing an idea about the data distribution.

## Frequency Distribution of Qualitative Data in R

Qualitative data is expressed in the form of values that can’t be expressed in the form of numbers but in the form of characters or string variables.

A data frame can be created using the data.frame method in R. It can append to operations using the pipe operator. It can be subjected to the count() method which is used to calculate the counts of each of the encountered string values. All the column values specified in the count() method are displayed in the output.

`count(df-col)`

## R

 `library``(``"dplyr"``) ` `#using a func to generate values ` `#creating a data frame ` ` `  `data_frame <- ``data.frame``(col1 = ``c``(``"Maths"``,``"Physics"``,``"Chem"``,``"Bio"``,``"Bio"``, ` `                                 ``"Maths"``,``"Physics"``,``"Chem"``,``"Maths"``,``"Physics"``, ` `                                 ``"Chem"``,``"Bio"``,``"Physics"``,``"Physics"``,``"Chem"``)) ` `print``(``"Original Data"``) ` `print``(data_frame) ` `#creating a frequency table using col1 columns of data frame ` `data_frame %>% ` ` ``count``(col1)`

Output:

R also contains an in-built method to depict the frequency table of the data. The data frame column to be used to computed the frequencies is used as an input parameter in the table method. The respective counts of the variables are returned as an output. A data table is returned as an output of this method.

`table(df-col)`

## R

 `library``(``"dplyr"``) ` `#using a func to generate values ` `#creating a data frame ` ` `  `data_frame <- ``data.frame``(col1 = ``c``(``"Maths"``,``"Physics"``,``"Chem"``,``"Bio"``,``"Bio"``, ` `                                 ``"Maths"``,``"Physics"``,``"Chem"``,``"Maths"``,``"Physics"``, ` `                                 ``"Chem"``,``"Bio"``,``"Physics"``,``"Physics"``,``"Chem"``)) ` `print``(``"Original Data"``) ` `print``(data_frame) ` `#creating a frequency table using col1 columns of data frame ` `freq_table <- ``table``(data_frame\$col1) ` `print``(``"Frequency table"``) ` `print``(freq_table)`

Output:

The dplyr package is used to perform simulations in the data by performing manipulations and transformations. It can be installed into the working space using the following command :

`install.packages("dplyr")`

Multiple columns can also be used to compute frequencies of the values of the input columns. All the unique sets belonging to these columns are chosen as the rows of the computed output. The columns appearing in the count() method are returned in the output. The group_by component has to be specified in order to indicate the grouping column to be used in the output.

## R

 `library``(dplyr) ` `#creating a data frame ` ` `  `data_frame <- ``data.frame``(col1 = ``c``(``"Geeks"``,``"Coding"``,``"Programming"``,``"Coding"``, ` `                                  ``"Coding"``,``"Coding"``,``"Programming"``,``"Geeks"``, ` `                                  ``"Learning"``,``"Programming"``,``"Geeks"``,``"Learning"` `), ` `                        ``grp = ``c``(``rep``(``c``(``"a"``,``"b"``,``"c"``),4))) ` `print``(``"Original Data"``) ` `print``(data_frame) ` ` `  `#creating a frequency table using col1 and grp columns of data frame ` `data_frame %>% ` ` ``count``(col1, grp) %>% ` ` ``group_by``(grp)`

Output:

My Personal Notes arrow_drop_up
Related Articles