library(readxl)
q1 <- read_excel("data/Copy of 2022 BOL2024 Week9 Data Entry THURS.xlsx", sheet = 2)
## New names:
## • `` -> `...11`
## • `` -> `...12`
## • `` -> `...13`
View(q1)
rgreen <- q1$RGreen
rgrey <- q1$RGrey
agreen <- q1$AGreen
agrey <- q1$AGrey
shapiro.test(rgreen)
##
## Shapiro-Wilk normality test
##
## data: rgreen
## W = 0.82872, p-value = 4.23e-11
shapiro.test(rgrey)
##
## Shapiro-Wilk normality test
##
## data: rgrey
## W = 0.7781, p-value = 7.459e-13
shapiro.test(agreen)
##
## Shapiro-Wilk normality test
##
## data: agreen
## W = 0.68194, p-value = 1.561e-15
shapiro.test(agrey)
##
## Shapiro-Wilk normality test
##
## data: agrey
## W = 0.70966, p-value = 7.92e-15
Data non-normal, perform Wilcoxon signed-rank test
wilcox.test(rgreen, rgrey, paired=TRUE)
##
## Wilcoxon signed rank test with continuity correction
##
## data: rgreen and rgrey
## V = 2882.5, p-value = 6.801e-05
## alternative hypothesis: true location shift is not equal to 0
p<0.05, reject H0, thus significant difference in mean sp. richness in green & grey
wilcox.test(agreen, agrey, paired=TRUE)
##
## Wilcoxon signed rank test with continuity correction
##
## data: agreen and agrey
## V = 3965.5, p-value = 2.19e-05
## alternative hypothesis: true location shift is not equal to 0
p<0.05, reject H0, thus significant difference in mean sp. abundance in green & grey
ie. to answer Q1, there is a significant difference between species richness and species abudance in both habitats.
library(readxl)
q2r <- read_excel("data/Copy of 2022 BOL2024 Week9 Data Entry THURS.xlsx", sheet = 3)
View(q2r)
q2r$Habitat <- as.factor(q2r$Habitat)
q2r$Origin <- as.factor(q2r$Origin)
str(q2r)
## tibble [264 × 3] (S3: tbl_df/tbl/data.frame)
## $ Habitat : Factor w/ 2 levels "Green","Grey": 1 1 1 1 1 1 1 1 1 1 ...
## $ Origin : Factor w/ 2 levels "Introduced","Native": 1 1 1 1 1 1 1 1 1 1 ...
## $ Richness: num [1:264] 1 0 1 2 0 1 1 0 1 1 ...
rhab <- q2r$Habitat
rorigin <- q2r$Origin
rich <- q2r$Richness
r.aov <- aov(rich ~ rhab + rorigin + rhab : rorigin, data = q2r)
summary(r.aov)
## Df Sum Sq Mean Sq F value Pr(>F)
## rhab 1 13.64 13.64 12.54 0.000473 ***
## rorigin 1 101.95 101.95 93.71 < 2e-16 ***
## rhab:rorigin 1 18.53 18.53 17.03 4.95e-05 ***
## Residuals 260 282.84 1.09
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
library(readxl)
q2a <- read_excel("data/Copy of 2022 BOL2024 Week9 Data Entry THURS.xlsx", sheet = 4)
View(q2a)
q2a$Habitat <- as.factor(q2r$Habitat)
q2a$Origin <- as.factor(q2r$Origin)
str(q2r)
## tibble [264 × 3] (S3: tbl_df/tbl/data.frame)
## $ Habitat : Factor w/ 2 levels "Green","Grey": 1 1 1 1 1 1 1 1 1 1 ...
## $ Origin : Factor w/ 2 levels "Introduced","Native": 1 1 1 1 1 1 1 1 1 1 ...
## $ Richness: num [1:264] 1 0 1 2 0 1 1 0 1 1 ...
ahab <- q2a$Habitat
aorigin <- q2a$Origin
abun <- q2a$Abundance
a.aov <- aov(abun ~ ahab + aorigin + ahab : aorigin, data = q2a)
summary(a.aov)
## Df Sum Sq Mean Sq F value Pr(>F)
## ahab 1 325 325.2 14.80 0.000150 ***
## aorigin 1 286 285.5 13.00 0.000374 ***
## ahab:aorigin 1 367 367.4 16.72 5.78e-05 ***
## Residuals 260 5713 22.0
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
library(readxl)
q3 <- read_excel("data/Copy of 2022 BOL2024 Week9 Data Entry THURS.xlsx", sheet = 5)
View(q3)
rpt <- q3$RPoint
rtrans <- q3$RTrans
apt <- q3$APoint
atrans <- q3$ATrans
wilcox.test(rpt, rtrans, paired=TRUE)
## Warning in wilcox.test.default(rpt, rtrans, paired = TRUE): cannot compute exact
## p-value with ties
## Warning in wilcox.test.default(rpt, rtrans, paired = TRUE): cannot compute exact
## p-value with zeroes
##
## Wilcoxon signed rank test with continuity correction
##
## data: rpt and rtrans
## V = 136, p-value = 0.0003821
## alternative hypothesis: true location shift is not equal to 0
wilcox.test(apt, atrans, paired=TRUE)
## Warning in wilcox.test.default(apt, atrans, paired = TRUE): cannot compute exact
## p-value with ties
## Warning in wilcox.test.default(apt, atrans, paired = TRUE): cannot compute exact
## p-value with zeroes
##
## Wilcoxon signed rank test with continuity correction
##
## data: apt and atrans
## V = 278.5, p-value = 0.001434
## alternative hypothesis: true location shift is not equal to 0