Organize Discrete Data in Tables

We will use the data from Table 8 in Section 2.2. Enter the data into R. Either use the c(…) command or read.csv command.

Using the c(…) command:

Arrivals <- c(7,5,2,6,2,6,6,7,5,2,6,6,1,5,9,6,11,2,3,7,4,4,4,7,5,6,5,8,5,9,2,7,2,4,8,6,6,6,6,5)

To add a column name to the data, create a data frame.

Table8 <- data.frame("Arrivals"=Arrivals)

Using read.csv:

Table8 <- read.csv("https://sullystats.github.io/Statistics6e/Data/Chapter2/Table8.csv")

We will use the Mosaic package. If you have not installed the package, use the following:

install.packages("mosaic")

Call the Mosaic library.

library(mosaic)

Use the tally command in Mosaic to build a frequency and relative frequency distribution.

tally(~Arrivals,data=Table8)
## Arrivals
##  1  2  3  4  5  6  7  8  9 11 
##  1  6  1  4  7 11  5  2  2  1
tally(~Arrivals,format="proportion",data=Table8)
## Arrivals
##     1     2     3     4     5     6     7     8     9    11 
## 0.025 0.150 0.025 0.100 0.175 0.275 0.125 0.050 0.050 0.025

Be careful when reading the output. Any “missing observation (such as 10) is skipped.