Load the data into R. We will use Table 1 from Section 2.1.

Table1 <- read.csv("https://sullystats.github.io/Stats7e/Data/Ch2/Table1.csv")
## If using Stats6e:
## Table1 <- read.csv("https://sullystats.github.io/Statistics6e/Data/Chapter2/Table1.csv")
head(Table1,n=4)
##   Location
## 1     Back
## 2    Wrist
## 3    Elbow
## 4     Back

If you have not done so already, install the Mosaic package.

install.packages("mosaic")

The Tally Command in Mosaic

First, we will find the frequency distribution. The syntax in Mosaic is

tally(~var_name,data=df_name)

library(mosaic)
tally(~Location,data=Table1)
## Location
##     Back    Elbow    Groin     Hand      Hip     Knee     Neck Shoulder 
##       12        1        1        2        2        5        1        4 
##    Wrist 
##        2

To get a relative frequency distribution add the command format=“proportion”.

tally(~Location,format="proportion",data=Table1)
## Location
##       Back      Elbow      Groin       Hand        Hip       Knee       Neck 
## 0.40000000 0.03333333 0.03333333 0.06666667 0.06666667 0.16666667 0.03333333 
##   Shoulder      Wrist 
## 0.13333333 0.06666667