+ Show code- Hide code
library(OpasnetUtils)
library(ggplot2)
library(igraph)
summary_data <- opbase.data("Op_en5865",subset="Literary review summary")
authors <- opbase.data("Op_en5865",subset="Literary review authors")
#levels(summary_data$Article)
#levels(authors$Article)
#oprint(authors)
authors_summary <- merge(summary_data, authors,by="Article") # Merged tables
#oprint(authors_summary)
authors_short <- authors_summary[,c("Trait","Hypothesis","Result.x","Result.y")] # Irrelevant columns taken out
#oprint(authors_short)
authors_uniq <- unique(authors_short) # A list of authors only defending of attacking one hypothesis once.
#oprint(authors_uniq)
#ggplot(data=summary_data, aes(summary_data$Result)) + geom_histogram()
ggplot(summary_data, aes(Result, fill = Hypothesis)) + geom_histogram() # eri hypoteesit eri värillä
ggplot(summary_data, aes(Hypothesis, fill = Result)) + geom_histogram() # F/A/N eri värillä hypoteeseittain.
# Tässä lyhennetty koodia, koska 'data=' ei tarvita ja data.framen nimeä ei tarvita mainita aes:n sisällä vaan riittää sarakkeen nimi.
# Tästä eteenpäin bipedalismi hypoteeseja
#ggplot(summary_data[summary_data$Hypothesis == "Carrying baby",], aes(Result)) + geom_histogram(fill="blue") + labs(title="Carrying baby") + labs(x="", y="Count") + theme_grey(base_size=24)
#ggplot(summary_data[summary_data$Hypothesis == "Carrying food",], aes(Result)) + geom_histogram(fill="blue") + labs(title="Carrying food") + labs(x="", y="Count") + theme_grey(base_size=24)
#ggplot(summary_data[summary_data$Hypothesis == "Energy efficiency",], aes(Result)) + geom_histogram(fill="blue") + labs(title="Energy efficiency") + labs(x="", y="Count") + theme_grey(base_size=24)
#ggplot(summary_data[summary_data$Hypothesis == "Thermoregulation-b",], aes(Result)) + geom_histogram(fill="blue") + labs(title="Thermoregulation") + labs(x="", y="Count") + theme_grey(base_size=24)
#ggplot(summary_data[summary_data$Hypothesis == "Thinner branches",], aes(Result)) + geom_histogram(fill="blue") + labs(title="Thinner branches") + labs(x="", y="Count") + theme_grey(base_size=24)
biped <- ggplot(summary_data[summary_data$Trait == "Bipedalism",], aes(Result)) + geom_histogram(fill="blue") + labs(x="", y="Count") + labs(title="Bipedalism in articles") + theme_grey(base_size=24)
biped + facet_wrap(~Hypothesis, ncol=3)
biped_authors <- ggplot(authors_uniq[authors_uniq$Trait == "Bipedalism",], aes(Result.x)) + geom_histogram(fill="blue") + labs(x="", y="Count") + labs(title="Bipedalism by author") + theme_grey(base_size=24)
biped_authors + facet_wrap(~Hypothesis, ncol=3)
ggplot(summary_data[summary_data$Trait == "Bipedalism",], aes(Hypothesis, fill = Result)) + geom_histogram() + labs(title="Bipedalism in articles") + labs(x="", y="Count") + theme_grey(base_size=24)
ggplot(authors_uniq[authors_uniq$Trait == "Bipedalism",], aes(Hypothesis, fill = Result.x)) + geom_histogram() + labs(title="Bipedalism by author") + labs(x="", y="Count") + theme_grey(base_size=24)
#ggplot(summary_data[c((summary_data$Trait=="Bipedalism",),(summary_data$Year>1999,)], aes(Hypothesis, fill = Result)) + geom_histogram() + labs(title="Bipedalism by author") + labs(x="", y="Count") + theme_grey(base_size=24) # Ei toimi!
# Tästä eteenpäin aivohypoteeseja
#ggplot(summary_data[summary_data$Hypothesis == "Fish",], aes(Result)) + geom_histogram(fill="blue") + labs(title="Eating fish") + labs(x="", y="Count") + theme_grey(base_size=24)
#ggplot(summary_data[summary_data$Hypothesis == "Social",], aes(Result)) + geom_histogram(fill="blue") + labs(title="Social brain") + labs(x="", y="Count") + theme_grey(base_size=24)
brain <- ggplot(summary_data[summary_data$Trait == "Brain",], aes(Result)) + geom_histogram(fill="blue") + labs(x="", y="Count") + labs(title="Brain in articles") + theme_grey(base_size=24)
brain + facet_wrap(~Hypothesis, ncol=3)
brain_authors <- ggplot(authors_uniq[authors_uniq$Trait == "Brain",], aes(Result.x)) + geom_histogram(fill="blue") + labs(x="", y="Count") + labs(title="Brain by author") + theme_grey(base_size=24)
brain_authors + facet_wrap(~Hypothesis, ncol=3)
ggplot(summary_data[summary_data$Trait == "Brain",], aes(Hypothesis, fill = Result)) + geom_histogram() + labs(title="Brain in articles") + labs(x="", y="Count") + theme_grey(base_size=24)
ggplot(authors_uniq[authors_uniq$Trait == "Brain",], aes(Hypothesis, fill = Result.x)) + geom_histogram() + labs(title="Brain by authors") + labs(x="", y="Count") + theme_grey(base_size=24)
# Tästä eteenpäin rasvahypoteeseja
fat <- ggplot(summary_data[summary_data$Trait == "Fat",], aes(Result)) + geom_histogram(fill="blue") + labs(x="", y="Count") + labs(title="Subcutaneous fat in articles") + theme_grey(base_size=24)
fat + facet_wrap(~Hypothesis, ncol=3)
fat_authors <- ggplot(authors_uniq[authors_uniq$Trait == "Fat",], aes(Result.x)) + geom_histogram(fill="blue") + labs(x="", y="Count") + labs(title="Subcutaneous fat by author") + theme_grey(base_size=24)
fat_authors + facet_wrap(~Hypothesis, ncol=3)
ggplot(summary_data[summary_data$Trait == "Fat",], aes(Hypothesis, fill = Result)) + geom_histogram() + labs(title="Subcutaneous fat in articles") + labs(x="", y="Count") + theme_grey(base_size=24)
ggplot(authors_uniq[authors_uniq$Trait == "Fat",], aes(Hypothesis, fill = Result.x)) + geom_histogram() + labs(title="Subcutaneous fat by author") + labs(x="", y="Count") + theme_grey(base_size=24)
#Tästä eteenpäin karvattomuushypoteeseja
#ggplot(summary_data[summary_data$Hypothesis == "Clothes",], aes(Result)) + geom_histogram(fill="blue") + labs(title="Clothes") + labs(x="", y="Count") + theme_grey(base_size=24)
#ggplot(summary_data[summary_data$Hypothesis == "Ectoparasites",], aes(Result)) + geom_histogram(fill="blue") + labs(title="Ectoparasites") + labs(x="", y="Count") + theme_grey(base_size=24)
#ggplot(summary_data[summary_data$Hypothesis == "Thermoregulation-h",], aes(Result)) + geom_histogram(fill="blue") + labs(title="Thermoregulation") + labs(x="", y="Count") + theme_grey(base_size=24)
hair <- ggplot(summary_data[summary_data$Trait == "Hairlessness",], aes(Result)) + geom_histogram(fill="blue") + labs(x="", y="Count") + labs(title="Hairlessness in articles") + theme_grey(base_size=24)
hair + facet_wrap(~Hypothesis, ncol=3)
hair_authors <- ggplot(authors_uniq[authors_uniq$Trait == "Hairlessness",], aes(Result.x)) + geom_histogram(fill="blue") + labs(x="", y="Count") + labs(title="Hairlessness by author") + theme_grey(base_size=24)
hair_authors + facet_wrap(~Hypothesis, ncol=3)
ggplot(summary_data[summary_data$Trait == "Hairlessness",], aes(Hypothesis, fill = Result)) + geom_histogram() + labs(title="Hairlessness in articles") + labs(x="", y="Count") + theme_grey(base_size=24)
ggplot(authors_uniq[authors_uniq$Trait == "Hairlessness",], aes(Hypothesis, fill = Result.x)) + geom_histogram() + labs(title="Hairlessness by authors") + labs(x="", y="Count") + theme_grey(base_size=24)
# Tästä eteenpäin kurkunpäähypoteeseja
larynx <- ggplot(summary_data[summary_data$Trait == "Larynx",], aes(Result)) + geom_histogram(fill="blue") + labs(x="", y="Count") + labs(title="Larynx in articles") + theme_grey(base_size=24)
larynx + facet_wrap(~Hypothesis, ncol=3)
larynx_authors <- ggplot(authors_uniq[authors_uniq$Trait == "Larynx",], aes(Result.x)) + geom_histogram(fill="blue") + labs(x="", y="Count") + labs(title="Larynx by author") + theme_grey(base_size=24)
larynx_authors + facet_wrap(~Hypothesis, ncol=3)
ggplot(summary_data[summary_data$Trait == "Larynx",], aes(Hypothesis, fill = Result)) + geom_histogram() + labs(title="Larynx in articles") + labs(x="", y="Count") + theme_grey(base_size=24)
ggplot(authors_uniq[authors_uniq$Trait == "Larynx",], aes(Hypothesis, fill = Result.x)) + geom_histogram() + labs(title="Larynx by authors") + labs(x="", y="Count") + theme_grey(base_size=24)
#Tästä eteenpäin puhehypoteeseja
speech <- ggplot(summary_data[summary_data$Trait == "Speech",], aes(Result)) + geom_histogram(fill="blue") + labs(x="", y="Count", title="Speech in articles") + theme_grey(base_size=24)
speech + facet_wrap(~Hypothesis, ncol=3)
speech_authors <- ggplot(authors_uniq[authors_uniq$Trait == "Speech",], aes(Result.x)) + geom_histogram(fill="blue") + labs(x="", y="Count") + labs(title="Speech by author") + theme_grey(base_size=24)
speech_authors + facet_wrap(~Hypothesis, ncol=3)
ggplot(summary_data[summary_data$Trait == "Speech",], aes(Hypothesis, fill = Result)) + geom_histogram() + labs(title="Speech in articles") + labs(x="", y="Count") + theme_grey(base_size=24)
ggplot(authors_uniq[authors_uniq$Trait == "Speech",], aes(Hypothesis, fill = Result.x)) + geom_histogram() + labs(title="Speech by authors") + labs(x="", y="Count") + theme_grey(base_size=24)
#Tästä eteenpäin muita hypoteeseja
other <- ggplot(summary_data[summary_data$Trait == "Other",], aes (Result)) + geom_histogram(fill="blue") + labs(x="", y="Count") + labs (title="Other human traits in articles") + theme_grey(base_size=24)
other + facet_wrap(~Hypothesis, ncol=3)
other_authors <- ggplot(authors_uniq[authors_uniq$Trait == "Other",], aes (Result.x)) + geom_histogram(fill="blue") + labs(x="", y="Count") + labs (title="Other human traits by author") + theme_grey(base_size=24)
other_authors + facet_wrap(~Hypothesis, ncol=3)
#oprint(odag)
#?odag
#odag()
authors_for <- authors_uniq[authors_uniq$Result.x == "F",]
oprint(authors_for)
authors_against <- authors_uniq[authors_uniq$Result.x == "A",]
oprint(authors_against)
edg <- data.frame(
from = authors_uniq$Result.y,
to = authors_uniq$Hypothesis,
Trait = authors_uniq$Trait,
FAN = authors_uniq$Result.x
)
ver <- rbind(
data.frame(
name = authors_uniq$Result.y,
Trait = NA
),
data.frame(
name = authors_uniq$Hypothesis,
Trait = authors_uniq$Trait
)
)
ver <- ver[!duplicated(ver$name) , ]
ver$Type <- ifelse(ver$name %in% authors_uniq$Hypothesis, "Hypothesis", "Author")
dag <- graph.data.frame(edg, directed = TRUE, vertices = ver)
colo <- c("Red", "Blue", "Pink", "Orange", "Brown", "Yellow", "Purple")
plot(
dag,
vertex.label.cex = 0.4,
vertex.size = ifelse(V(dag)$Type == "Hypothesis", 6, 3),,
vertex.color = ifelse(V(dag)$Type == "Hypothesis",
colo[as.factor(V(dag)$Trait)],
"SkyBlue2"
),
vertex.label = ifelse(V(dag)$Type == "Hypothesis", V(dag)$name, NA),
edge.color = c("Red", "Green", "Gray")[as.factor(E(dag)$FAN)],
edge.arrow.size = 0.3,
layout = layout.fruchterman.reingold,
asp = 0.7
)
| |