Relative Frequency Table In R
Relative Frequency Distribution of Qualitative Data
The relative frequency distribution of a information variable is a summary of the frequency proportion in a collection of non-overlapping categories.
The relationship of frequency and relative frequency is:
Instance
In the data set painters, the relative frequency distribution of the School variable is a summary of the proportion of painters in each schoolhouse.
Problem
Find the relative frequency distribution of the painter schools in the data set painters.
Solution
Nosotros first apply the table function to compute the frequency distribution of the School variable.
> library(MASS) # load the MASS package
> schoolhouse = painters$Schoolhouse # the painter schools
> schoolhouse.freq = table(school) # utilize the table function
So we discover the sample size of painters with the nrow function, and divide the frequency distribution with it. Therefore the relative frequency distribution is:
> school.relfreq = school.freq / nrow(painters)
Answer
The relative frequency distribution of the schools is:
> school.relfreq
school
A B C D E F
0.185185 0.111111 0.111111 0.185185 0.129630 0.074074
G H
0.129630 0.074074
Enhanced Solution
We tin print with fewer digits and make it more than readable past setting the digits option.
> old = options(digits=1)
> school.relfreq
school
A B C D E F G H
0.xix 0.xi 0.eleven 0.19 0.13 0.07 0.13 0.07
> options(quondam)
In improver, we can employ the cbind function to print the result in column format.
> old = options(digits=i)
> cbind(school.relfreq)
schoolhouse.relfreq
A 0.19
B 0.11
C 0.11
D 0.19
E 0.thirteen
F 0.07
G 0.13
H 0.07
> options(former) # restore the onetime option
Exercise
Discover the relative frequency distribution of the composition scores in painters.
Relative Frequency Table In R,
Source: http://www.r-tutor.com/elementary-statistics/qualitative-data/relative-frequency-distribution-qualitative-data
Posted by: hansfordablared1984.blogspot.com

0 Response to "Relative Frequency Table In R"
Post a Comment