-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathforum_hadriani.R
57 lines (41 loc) · 2.37 KB
/
forum_hadriani.R
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
library(readxl)
library(dplyr)
library(ggplot2)
library(RColorBrewer)
library(pastecs)
library(ggpubr)
# read data
forum <- read_excel("data/forumhadriani.xlsx")
# directory for export
dir.create("export", showWarnings = FALSE)
ggplot(forum, aes(x=FellingAge)) + geom_histogram(binwidth = 20, color="darkblue", fill="lightblue") +
xlab("Tree age (years)") + ylab("Frequency")
ggsave("export/forum_treeage_histogram.png", width = 12, height = 8)
felling_age_hist <- ggplot(forum, aes(x=FellingAge)) + geom_histogram(binwidth = 20, color="darkblue", fill="lightblue") +
xlab("Tree age (years)") + ylab("Frequency") + facet_grid(~Provenance)
ggsave("export/forum_treeage_region_histogram.png", felling_age_hist, width = 12, height = 8)
ggplot(forum, aes(x=FellingAge)) + geom_density()
#ggplot(forum, aes(x=FellingAge)) + geom_boxplot()
stat.desc(forum$FellingAge)
prov_freq <- as.data.frame(table(forum$Provenance))
colnames(prov_freq) <-c("English", "freq")
colourCount = length(prov_freq[,1])
getPalette = colorRampPalette(brewer.pal(colourCount, "Set1"))
provenance_pie <- ggplot(prov_freq, aes(x="",y=freq,fill=English)) +
geom_bar(width = 1, stat = "identity") + coord_polar(theta = "y") +
theme(axis.text.x=element_blank()) + theme_void() + theme(strip.text = element_text(size = 5)) +
scale_fill_manual(values = getPalette(colourCount), labels = paste0(prov_freq$English, " (", prov_freq$freq, ")")) +
guides(fill=guide_legend(title="Context"))
#geom_text(aes(label = freq), position = position_stack(vjust = 0.5),size=3)
ggsave("export/forum_provenance_pie.png", provenance_pie, dpi = 300, width = 8, height = 6)
felling_dates <- ggplot(forum, aes(y=FellingAge,x=FellingDate, color=Provenance)) + geom_point() +
scale_colour_manual(values = getPalette(3)) +
xlab("Felling year") + ylab ("Felling Age")
ggsave("export/forum_felling_dates_age_scatter.png", felling_dates, width = 12, height = 8)
ggplot(forum, aes(x=FellingDate)) + geom_histogram(binwidth = 25, color="darkblue", fill="lightblue") +
xlab("Felling year") + ylab ("Count")
ggsave("export/forum_felling_histogram.png", width = 12, height = 8)
ggarrange(felling_dates,
ggarrange(felling_age_hist, provenance_pie, ncol = 2, labels = c("B", "C")),
nrow = 2, labels = "A")
ggsave("export/forum_combined.png", dpi = 300, width = 10, height = 10)