library(bitops)
library(RCurl)
library(tidyverse)
library(ggplot2)
dryeye<- getURL("https://raw.githubusercontent.com/sookuan/S-SB-Workshop/master/00-R-In-Class/DryEye.csv")
DryEye<- read.csv(text = dryeye)
head(DryEye)
## notreat herb
## 1 2.372074 1.4766453
## 2 1.957100 1.3228087
## 3 1.996542 0.9665124
## 4 2.087404 1.3491698
## 5 1.815421 1.2702050
## 6 1.402811 1.0759150
str(DryEye)
## 'data.frame': 50 obs. of 2 variables:
## $ notreat: num 2.37 1.96 2 2.09 1.82 ...
## $ herb : num 1.477 1.323 0.967 1.349 1.27 ...
dim(DryEye)
## [1] 50 2
DryEye %>%
gather(treatment, redness, notreat:herb) %>%
filter(treatment == "notreat") %>%
ggplot(aes(x=treatment, y = redness)) +
geom_boxplot(outlier.colour='red', outlier.shape = 8, outlier.size=4) +
labs(title="Conjunctival Redness before Herb Treatment", x = "Before Herb Treatment", y = "Conjunctival Redness")
DryEye %>%
gather(treatment, redness, notreat:herb) %>%
filter(treatment == "herb") %>%
ggplot(aes(x=treatment, y = redness)) +
geom_boxplot(outlier.colour='red', outlier.shape = 8, outlier.size=4) +
labs(title="Conjunctival Redness after Herb Treatment", x = "After Herb Treatment", y = "Conjunctival Redness")
DryEye %>%
gather(treatment, redness, notreat:herb) %>%
filter(treatment == "notreat") %>%
ggplot(aes(x = redness)) +
geom_histogram()
qqnorm(DryEye$notreat, pch = 1)
qqline(DryEye$notreat, col = "red", lwd = 2)
### The data exhibit straight line = normal distribute
DryEye %>%
gather(treatment, redness, notreat:herb) %>%
filter(treatment == "herb") %>%
ggplot(aes(x = redness)) +
geom_histogram()
qqnorm(DryEye$herb, pch = 1)
qqline(DryEye$herb, col = "red", lwd = 2)
### The data fit the straight line if exclude the outlier ~ normal distribute
qqplot(DryEye$notreat, DryEye$herb)
shapiro.test(DryEye$notreat)
##
## Shapiro-Wilk normality test
##
## data: DryEye$notreat
## W = 0.98351, p-value = 0.7062
shapiro.test(DryEye$herb)
##
## Shapiro-Wilk normality test
##
## data: DryEye$herb
## W = 0.97509, p-value = 0.3678
t.test(DryEye$notreat, DryEye$herb)
##
## Welch Two Sample t-test
##
## data: DryEye$notreat and DryEye$herb
## t = 3.4944, df = 77.329, p-value = 0.0007897
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 0.1235924 0.4509954
## sample estimates:
## mean of x mean of y
## 1.303158 1.015864