How to make and calculate the Frequency Distribution Table in R?

Asked

Viewed 16,303 times

5

I’m trying to make the Frequency distribution table in R, however, I am not succeeding due to some formulas and calculations that I cannot implement in R.

The structure of the frequency distribution table is as follows:

-------------------------------------
|Dados | Xi | Fi | Fr | Fac | Xi.Fi |
|      |    |    |    |     |       |
|      |    |    |    |     |       |
-------------------------------------

I don’t know how to calculate the values of Xi, Fi, Fr, Fac, Xi.Fi and I didn’t understand very well what they represent in this table.

There are also other calculations that must be done which is Amplitude, Quantity of Elements and Range size. In which I had the same difficulties to do too.

Dice

The ROLL that I’m using to make the frequency distribution table is this corresponding to the age of students:

Dados idade - Tabela

The ROL values I use in R are:

18 19 19 19 19 19 19 19 19 19 19 19 20 20 22 23 24 26 26 30 32

Question

How can I make the Frequency Distribution Table of these data above in R?

1 answer

9


For the first part of the question, the code below can help you

library(dplyr)
dados <- c(18,19,19,19,19,19,19,19,19,19,19,19,20,20,22,23,24,26,26,30,32)
tabela <- data.frame(t(table(dados)))[,-1]
tabela$dados <- as.numeric(levels(tabela$dados))
tabela <- tabela %>% 
  mutate(Fr = 100*Freq/sum(Freq),
         Fac = cumsum(Freq),
         Xi.Fi = dados*Freq)
tabela

as to your doubts, Xiand Dados of the table structure that you put, it’s the same thing, it’s all the values that your variable can assume. Fi represents the frequency at which each variable value occurs. Fr is the relative frequency, Faq is the cumulative frequency and Xi.Fi is the multiplication of each variable value by its respective frequency.

I suggest you take some material or book of Basic Statistics. You will find this part that explains the creation of frequency table.

As for the second part, of the other calculations, the same book (or material) must have a part to create this table with intervals. There you will see the step by step for the creation of the same, then you will be able to respond to Amplitude, Element Quantity and Range Size.

More information about this here.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.