The following data refers to the incubation period expressed in days for a certain disease:
5 2 4 5 6 7 4 7 5 2 3 6 7 5 5 4 1 6 6 5 8 4 2 6 5 8 7 4 4 6 9 5 3 5 5 6 6 3 4 5
Calculate using R the frequency distribution (absolute, relative, relative percentage, cumulative relative percentage).
SOLUTION
Create the incubation vector
Incubazione <- c(5, 2, 4, 5, 6, 7, 4, 7, 5, 2, 3, 6, 7, 5, 5, 4, 1, 6, 6, 5, 8, 4, 2, 6, 5, 8, 7, 4, 4, 6, 9, 5, 3, 5, 5, 6, 6, 3, 4, 5) length(Incubazione)
Absolute frequency distribution
table(Incubazione)
Relative frequency distribution
table(Incubazione) / length(Incubazione)
Check if the relative frequency distribution calculation is correct
sum(table(Incubazione) / length(Incubazione))
Relative percentage frequency distribution
table(Incubazione) / length(Incubazione) * 100
Cumulative relative percentage frequency distribution
cumsum(table(Incubazione) / length(Incubazione) * 100)