#read file

deer <- read.csv("deer.csv")

#make a vector of legolas actors, compare to aragorns and gimlis

aragorn = rnorm(50, mean=180, sd=10)
gimli = rnorm(50, mean=132, sd=15)
legolas = rnorm(50, mean=195, sd=15)
t.test(aragorn, legolas, alternative="two.sided")
## 
##  Welch Two Sample t-test
## 
## data:  aragorn and legolas
## t = -6.7443, df = 84.694, p-value = 1.78e-09
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -20.44653 -11.13545
## sample estimates:
## mean of x mean of y 
##  178.2497  194.0407
t.test(legolas, gimli, alternative="two.sided")
## 
##  Welch Two Sample t-test
## 
## data:  legolas and gimli
## t = 23.887, df = 96.483, p-value < 2.2e-16
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  57.12229 67.47553
## sample estimates:
## mean of x mean of y 
##  194.0407  131.7418

#run variance test to compare gimli and legolas actors

var.test(legolas, gimli)
## 
##  F test to compare two variances
## 
## data:  legolas and gimli
## F = 1.2868, num df = 49, denom df = 49, p-value = 0.3806
## alternative hypothesis: true ratio of variances is not equal to 1
## 95 percent confidence interval:
##  0.7302115 2.2675320
## sample estimates:
## ratio of variances 
##            1.28677

#redo correlation for sepal length and sepal width for iris dataset for individual species

cor.test(iris$Sepal.Length [iris$Species == "versicolor"], iris$Sepal.Width [iris$Species == "versicolor"])
## 
##  Pearson's product-moment correlation
## 
## data:  iris$Sepal.Length[iris$Species == "versicolor"] and iris$Sepal.Width[iris$Species == "versicolor"]
## t = 4.2839, df = 48, p-value = 8.772e-05
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.2900175 0.7015599
## sample estimates:
##       cor 
## 0.5259107
cor.test(iris$Sepal.Length [iris$Species == "setosa"], iris$Sepal.Width [iris$Species == "setosa"])
## 
##  Pearson's product-moment correlation
## 
## data:  iris$Sepal.Length[iris$Species == "setosa"] and iris$Sepal.Width[iris$Species == "setosa"]
## t = 7.6807, df = 48, p-value = 6.71e-10
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.5851391 0.8460314
## sample estimates:
##       cor 
## 0.7425467
cor.test(iris$Sepal.Length [iris$Species == "virginica"], iris$Sepal.Width [iris$Species == "virginica"])
## 
##  Pearson's product-moment correlation
## 
## data:  iris$Sepal.Length[iris$Species == "virginica"] and iris$Sepal.Width[iris$Species == "virginica"]
## t = 3.5619, df = 48, p-value = 0.0008435
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.2049657 0.6525292
## sample estimates:
##       cor 
## 0.4572278

#use deer dataset and chisq.test() to see if there are siginificant differences in number of deer caught per month

chisq.test(table(deer$Month))
## 
##  Chi-squared test for given probabilities
## 
## data:  table(deer$Month)
## X-squared = 997.07, df = 11, p-value < 2.2e-16

#use the chisq.test() to see fi the cases of tuberculosis are uniformly distributed across all farms

table(deer$Farm, deer$Tb)
##       
##          0   1
##   AL    10   3
##   AU    23   0
##   BA    67   5
##   BE     7   0
##   CB    88   3
##   CRC    4   0
##   HB    22   1
##   LCV    0   1
##   LN    28   6
##   MAN   27  24
##   MB    16   5
##   MO   186  31
##   NC    24   4
##   NV    18   1
##   PA    11   0
##   PN    39   0
##   QM    67   7
##   RF    23   1
##   RN    21   0
##   RO    31   0
##   SAL    0   1
##   SAU    3   0
##   SE    16  10
##   TI     9   0
##   TN    16   2
##   VISO  13   1
##   VY    15   4
chisq.test(table(deer$Farm, deer$Tb))
## Warning in chisq.test(table(deer$Farm, deer$Tb)): Chi-squared approximation may
## be incorrect
## 
##  Pearson's Chi-squared test
## 
## data:  table(deer$Farm, deer$Tb)
## X-squared = 129.09, df = 26, p-value = 1.243e-15