4 Making tables

Before we make the tables we will need to install and load the necessary packages. The package needed to manipulate data and create dataframe is the dplyr package.

  1. To help us compute the descriptive statistics of the data, we will need to install the dplyr package. The following code will help you to install this package. You may skip this step if you have already installed the package.
install.packages("dplyr")
  1. After successful installation, we will have to load it into R using the code
library(dplyr)
  1. Now we are good to manipulate the data and create data frames. The first dataframe gives a descriptive statistics (summary) of the skull length (SL_mm) by region.
coyoteSL <- coyote %>% filter(!is.na(coyote$SL_mm))
as.data.frame(summarize(group_by(coyoteSL, Region), SL_mean = mean(SL_mm),
                  SL_SD = sd(SL_mm), n = n()))
##   Region  SL_mean     SL_SD  n
## 1     AK 185.1677 14.247055 18
## 2    CTR 193.8521 10.399843 21
## 3     NE 200.3899 11.728498 21
## 4     NW 184.3920  7.916187 18
## 5     SE 200.3848 14.499354  2
## 6     SW 187.6740  8.427188 40
  1. The overall mean and standard deviation of the skull length and the number of skulls can be found by running this code:
as.data.frame(summarize(group_by(coyoteSL), SL_mean = mean(SL_mm),
                  SL_SD = sd(SL_mm), n = n()))
##   SL_mean    SL_SD   n
## 1 190.324 11.73755 120
  1. We can also create a dataframe that gives a summary of the braincase breadth (BB_mm) by region. This is done by running the code:
coyoteBB <- coyote %>% filter(!is.na(coyote$BB_mm))
as.data.frame(summarize(group_by(coyoteBB, Region), BB_mean = mean(BB_mm),
                  BB_SD = sd(BB_mm), n = n()))
##   Region  BB_mean    BB_SD  n
## 1     AK 56.20690 3.940768 18
## 2    CTR 57.27160 2.352801 21
## 3     NE 59.45019 2.398987 21
## 4     NW 56.95291 2.635666 18
## 5     SE 58.47589 3.135494  2
## 6     SW 56.53313 2.252482 39
  1. The overall mean and standard deviation of the braincase breadth (BB_mm) and the number of skulls measured can be found by running this code:
as.data.frame(summarize(group_by(coyoteBB), BB_mean = mean(BB_mm),
                  BB_SD = sd(BB_mm), n = n()))
##    BB_mean    BB_SD   n
## 1 57.22502 2.846884 119