The Data is in this study found at this link: Mammals
## Data Set Names are mammals, large mammals (lmam), and small mammals (smam)
## We call up the data as follows:
library(readr)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
mammals <-read.csv("https://www.dropbox.com/s/d5dnxumbwm13xjs/mammals.csv?dl=1", header=T)
smam <- filter(mammals, bodywt < 100)
lmam <- filter(mammals, bodywt >= 100)
View(mammals)
attach(mammals)
mean(gestation)
## [1] 142.0686
**Answer: The mean gestation period for all mammals is 142.0686 days.
median(gestation)
## [1] 100
**The median gestation period for all mammals is 100 days.
hist(gestation, col = "purple") #Q3
boxplot(gestation, main="All Mammals Gestation Period", horizontal=TRUE, col="lightblue",pch=16, cex=2, xlab="Number of Days")
**Answer From the histogram we see there are outliers and a right skew.
We confirm this with a boxplot showing the skew and two outlier
points.
range(brainwt)
## [1] 0.14 5712.00
range(bodywt)
## [1] 0.005 6654.000
** Answer: Bodyweight is more spread out from comparing the largest number and its distance from the smallest number. ## Question 5 Horizontal boxplots for total sleep, lifespan, and gestation are presented together. Which of these variables are the most symmetric?
boxplot(totalsleep, main="Total Sleep Time All Mammals",horizontal=TRUE, col = "lightblue", pch=16, cex=2, xlab="Number of Days")
boxplot(lifespan, main="LifeSpan All Mammals", horizontal = TRUE, col = "lightblue", pch=16, cex=2, xlab="Number of Days")
boxplot(gestation, main="All Mammals Gestation Period", horizontal=TRUE, col="lightblue",pch=16, cex=2, xlab="Number of Days")
mean(totalsleep)
## [1] 10.34902
mean(lifespan)
## [1] 20.14706
**Answer: From looking at the boxplots we see that total sleep is most symmetric.
smam <- filter(mammals, bodywt < 100)
View(smam)
lmam <- filter(mammals, bodywt >= 100)
View(lmam)
plot(lmam$gestation, lmam$totalsleep, main = "Sleep Needed for Large Mammal Gestation", col="lightblue4", pch=16, cex=1.25, ylab="gestation", xlab="Number of Days")
cor(lmam$gestation, lmam$totalsleep)
## [1] -0.6591753
**Answer: A correlation coefficient of -0.659 confirms that there is a midweight negative association between total sleep and gestation for large mammals.
mean(lmam$totalsleep)
## [1] 6.055556
mean(smam$totalsleep)
## [1] 11.26905
**Answer: Taking the average or mean of large and small mammals, we find that on average, small mammals have a higher average sleep time. Small mammals sleep an average of 11.27 while large mammals sleep an average of 6.056.
plot(smam$bodywt,smam$brainwt, main = "Small Mammal Brain Weight to Body Weight",col="lightblue4", pch=16, cex=1.25, ylab= "Brain Weight", xlab= "Body Weight")
**Answer: The influential point is the upper most brain weight point
corresponding to the upper most point. This influential point
corresponds to the Human.