-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.Rhistory
136 lines (136 loc) · 4.92 KB
/
.Rhistory
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
library(readr)
library(dplyr)
data <- read_delim("Zeitplan.csv",";", locale = locale(encoding = "Windows-1252")) %>%
mutate(
start = parse_date(start,format = "%d.%m.%Y"),
# start = strftime(start),
end = parse_date(end,format = "%d.%m.%Y"),
# end = strftime(end)
) %>%
filter(!is.na(content))
group <- read_delim("groups.csv",";", locale = locale(encoding = "Windows-1252"))
protokoll <- read_delim("Data/2017_SA2_Straub//Ereignisprotokoll.csv",";")
protokoll <- protokoll %>%
mutate(
start = as.POSIXct(paste(Datum,von),format = "%d.%m.%Y %H:%M:%S"),
end = as.POSIXct(paste(Datum,bis),format = "%d.%m.%Y %H:%M:%S")
)
format_hour <- function(hour_dec){
full_hour <- hour_dec %/% 1
partial_hour <- hour_dec %% 1
paste(full_hour,partial_hour*60,sep = ":")
}
round_fac <- 0.5
protokoll_smry <- protokoll %>%
filter(Tierart == "Hermelin") %>%
mutate(
h = hour(start) + minute(start)/60,
h = round(h/round_fac)*round_fac
) %>%
group_by(h) %>%
summarise(
sum = n()
) %>%
mutate(
hour_nice = format_hour(h)
)
ggplot(protokoll_smry, aes(h,sum)) +
geom_bar(stat = "identity", fill = zhaw_blue1, colour = "black") +
labs(x = "hour",
y = expression(paste(Sigma," der Detektionen")),
title = "Anzahl Detektionen pro halbe Stunde",
subtitle = "Gehegetests Hankensbüttel (SA2 Straub, 2017)") +
scale_x_continuous(breaks = protokoll_smry$h,labels = protokoll_smry$hour_nice) +
scale_y_continuous(sec.axis = sec_axis(~./9,name = expression(paste("Mittlere Anzahl pro Tag")))) +
theme_classic()
library(ggplot)
library(ggplot2)
ggplot(protokoll_smry, aes(h,sum)) +
geom_bar(stat = "identity", fill = zhaw_blue1, colour = "black") +
labs(x = "hour",
y = expression(paste(Sigma," der Detektionen")),
title = "Anzahl Detektionen pro halbe Stunde",
subtitle = "Gehegetests Hankensbüttel (SA2 Straub, 2017)") +
scale_x_continuous(breaks = protokoll_smry$h,labels = protokoll_smry$hour_nice) +
scale_y_continuous(sec.axis = sec_axis(~./9,name = expression(paste("Mittlere Anzahl pro Tag")))) +
theme_classic()
protokoll_smry <- protokoll %>%
filter(Tierart == "Hermelin") %>%
mutate(
h = hour(start) + minute(start)/60,
h = round(h/round_fac)*round_fac
) %>%
group_by(h) %>%
summarise(
sum = n()
) %>%
mutate(
hour_nice = format_hour(h)
)
library(lubridate)
protokoll_smry <- protokoll %>%
filter(Tierart == "Hermelin") %>%
mutate(
h = hour(start) + minute(start)/60,
h = round(h/round_fac)*round_fac
) %>%
group_by(h) %>%
summarise(
sum = n()
) %>%
mutate(
hour_nice = format_hour(h)
)
ggplot(protokoll_smry, aes(h,sum)) +
geom_bar(stat = "identity", fill = zhaw_blue1, colour = "black") +
labs(x = "hour",
y = expression(paste(Sigma," der Detektionen")),
title = "Anzahl Detektionen pro halbe Stunde",
subtitle = "Gehegetests Hankensbüttel (SA2 Straub, 2017)") +
scale_x_continuous(breaks = protokoll_smry$h,labels = protokoll_smry$hour_nice) +
scale_y_continuous(sec.axis = sec_axis(~./9,name = expression(paste("Mittlere Anzahl pro Tag")))) +
theme_classic()
zhaw_blue1 <- rgb(0,100,166,maxColorValue = 255)
zhaw_blue2 <- rgb(0,44,90,maxColorValue = 255)
ggplot(protokoll_smry, aes(h,sum)) +
geom_bar(stat = "identity", fill = zhaw_blue1, colour = "black") +
labs(x = "hour",
y = expression(paste(Sigma," der Detektionen")),
title = "Anzahl Detektionen pro halbe Stunde",
subtitle = "Gehegetests Hankensbüttel (SA2 Straub, 2017)") +
scale_x_continuous(breaks = protokoll_smry$h,labels = protokoll_smry$hour_nice) +
scale_y_continuous(sec.axis = sec_axis(~./9,name = expression(paste("Mittlere Anzahl pro Tag")))) +
theme_classic()
ggsave("images/protokoll_plot.jpg")
protokoll
ggplot(protokoll,aes(Tierart,as.integer(verweildauer))) +
geom_boxplot(fill = zhaw_blue1) +
labs(x="Art",
y="Verweildauer [s]",
title = "Verweildauer in der TubeCam in Abhängigkeit der Art",
subtitle = "Gehegetests Hankensbüttel (SA2 Straub, 2017)")+
stat_summary(fun.data = function(x){c(y = median(x)*1.05, label = length(x))}, geom = "label", fun.y = median) +
scale_x_discrete(labels = c(expression(atop(italic("M. erminea"),"(9 days)")),expression(atop(italic("M. nivalis"),"(1 day)")))) +
theme_classic()
protokoll %>%
filter(Tierart == "Hermelin") %>%
ggplot(aes(material,as.integer(verweildauer))) +
geom_boxplot(fill = zhaw_blue1) +
labs(x="Material",
y="Verweildauer [s]",
title = "Verweildauer in der TubeCam in Abhängigkeit des Materials",
subtitle = "Gehegetests Hankensbüttel (SA2 Straub, 2017)")+
scale_x_discrete(labels = c("Bitumen","PVC")) +
stat_summary(fun.data = function(x){c(y = median(x)*1.05, label = length(x))}, geom = "label", fun.y = median) +
theme_classic()
protokoll %>%
filter(Tierart == "Hermelin") %>%
ggplot(aes(material,as.integer(verweildauer))) +
geom_boxplot(fill = zhaw_blue1) +
labs(x="Material",
y="Verweildauer [s]",
title = "Verweildauer in der TubeCam in Abhängigkeit des Materials",
subtitle = "Gehegetests Hankensbüttel (SA2 Straub, 2017)")+
scale_x_discrete(labels = c("Bitumen","PVC")) +
stat_summary(fun.data = function(x){c(y = median(x)*1.05, label = length(x))}, geom = "label", fun = median) +
theme_classic()