-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path100DaysofCoding#day6+7.R
More file actions
86 lines (66 loc) · 2.06 KB
/
100DaysofCoding#day6+7.R
File metadata and controls
86 lines (66 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#Installing packages
install.packages("dplyr")
install.packages("ggplot2")
install.packages("lattice")
install.packages("wesanderson")
install.packages("tidyr")
install.packages("magritttr")
install.packages("ggfortify")
install.packages("gridExtra")
rm(list = ls())
#Libraries
library(dplyr)
library(ggplot2)
library(ggfortify)
library(lattice)
library(wesanderson)
library(tidyr)
library(magrittr)
library(ggfortify)
library(gridExtra)
file.choose()
growth.moo <- read.csv("D:\\Unine\\Unine\\Lessons\\5ème semestre\\Biostatistiques\\growth.csv")
str(growth.moo)
#Checking out the levels
levels(growth.moo$diet)
levels(growth.moo$supplement)
#Let's relevel to make "control" the reference
growth.moo <- mutate(growth.moo,
supplement = relevel(supplement, ref = "control"))
#Calculating the mean of gain according to diet and supplement
mean_growth <- growth.moo %>%
group_by(diet, supplement) %>%
summarise(mean_gain = mean(gain))
#Plotting
ggplot(mean_growth, aes(x = supplement, y = mean_gain, colour = diet, group = diet))+
geom_point()+
geom_line()+
theme_bw()
#X^2 and ladybugs
rm(list =ls())
file.choose()
ladybugs <- read.csv("D:\\Unine\\Unine\\Lessons\\5ème semestre\\Biostatistiques\\ladybirds_morph_colour.csv")
str(ladybugs)
sumLady <- ladybugs %>%
group_by(Habitat, morph_colour) %>%
summarise(sum_number = sum(number))
sumLady
ggplot(sumLady, aes(x = Habitat, y = sum_number, fill = morph_colour))+
geom_bar(stat = "identity", position = "dodge")+
xlab("Habitat")+
ylab("quantity")+
scale_fill_manual(values = c(black = "black", red = "red"))+
theme_bw()
ladymat <- xtabs(number~Habitat+morph_colour,
data = ladybugs)
chisq.test(ladymat)
#two-sample t-test and ozone
rm(list = ls())
file.choose()
ozone <- read.csv("D:\\Unine\\Unine\\Lessons\\5ème semestre\\Biostatistiques\\ozone.csv")
str(ozone)
head(ozone)
ggplot(ozone, aes(x = Ozone))+
geom_histogram(binwidth = 10)+
facet_wrap(~Garden.location, ncol = 1)
theme_bw()