Loading Beach Data

Beach <- read.csv("beach_data.csv")
summary(Beach)
##     Sample             Animal              Weight          Zone          
##  Length:30          Length:30          Min.   : 5.00   Length:30         
##  Class :character   Class :character   1st Qu.:12.25   Class :character  
##  Mode  :character   Mode  :character   Median :18.50   Mode  :character  
##                                        Mean   :22.60                     
##                                        3rd Qu.:29.50                     
##                                        Max.   :72.00

Answering some questions about our data

1. What is the mean and standard deviation of the weights?

sd(Beach$Weight)
## [1] 15.21705
mean(Beach$Weight)
## [1] 22.6

2. Plot the weights

barplot(Beach$Weight, names = Beach$Sample, col = "steelblue")

3. Is there a difference in weight between the animals?

aov(Beach$Weight~Beach$Animal)
## Call:
##    aov(formula = Beach$Weight ~ Beach$Animal)
## 
## Terms:
##                 Beach$Animal Residuals
## Sum of Squares      5163.069  1552.131
## Deg. of Freedom            6        23
## 
## Residual standard error: 8.214862
## Estimated effects may be unbalanced
summary(aov(Beach$Weight~Beach$Animal))
##              Df Sum Sq Mean Sq F value   Pr(>F)    
## Beach$Animal  6   5163   860.5   12.75 2.53e-06 ***
## Residuals    23   1552    67.5                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

4. What about the relationship between weight and tidal zone of animals?

summary(aov(Beach$Weight~Beach$Zone))
##             Df Sum Sq Mean Sq F value Pr(>F)  
## Beach$Zone   4   2239   559.8   3.127 0.0325 *
## Residuals   25   4476   179.0                 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

We find out that the mean weight of all animals in the data set is 22.6kg. Also we realized there is a relationship between weight and animals or tidal zones is significant and not due to chance.

Evaluating the anova model assumptions

anova1 <- lm(Beach$Weight~Beach$Animal, data = Beach)
plot(density(anova1$residuals))

anova2 <- lm(Beach$Weight~Beach$Zone, data = Beach)
plot(density(anova2$residuals))