You are on page 1of 2

# Check directory

getwd()
# Chage directory
setwd("/Users/melidanunecastillo/Desktop/R SCRIPTS/Basic Statistics")
# Create variables
M <- c("D13S317", "D13S317", "D13S317", "D13S317","D13S317", "D13S317", "D21S11",
"D21S11", "D21S11", "D21S11", "D21S11", "D21S11", "D21S11", "D21S11", "D18S51",
"D18S51", "D18S51", "D18S51", "D18S51", "D18S51", "D18S51", "D18S51", "D18S51",
"D18S51", "TH01", "TH01", "TH01", "TH01", "TH01", "TH01", "D5S818", "D5S818",
"D5S818", "D5S818", "D5S818", "D5S818", "FGA", "FGA", "FGA", "FGA", "FGA", "FGA",
"FGA", "FGA", "FGA")
A <- c("8", "9", "10", "11", "12", "13", "28", "29", "30", "30.2", "31", "31.2",
"32.2", "33.2", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "6",
"7", "8", "9", "9.3", "10", "9", "10", "11", "12", "13", "14", "18", "19", "20",
"21", "22", "23", "24", "25", "26")
P <- c(0.13636, 0.16667, 0.09091, 0.25758, 0.24242, 0.10606,0.06061, 0.24242,
0.28788, 0.0303, 0.0303, 0.22727, 0.10606, 0.01515, 0.0303, 0.19697, 0.18182,
0.21212, 0.07576, 0.15152, 0.06061, 0.0303, 0.04545, 0.01515, 0.25758, 0.13636,
0.22727, 0.22727, 0.10606, 0.04545, 0.09091, 0.36364, 0.06061, 0.27273, 0.16667,
0.04545, 0.06061, 0.13636, 0.07576, 0.0303, 0.07576, 0.19697, 0.21212, 0.15152,
0.06061)

O <- data.frame(M, A, P)
View(O)

names(O)

str(O)

library(ggplot2)
library(ggridges)
library(tidyverse)
library(hrbrthemes)
library(viridis)
library(plyr)

O$M <- factor(O$M,


levels = rev(c("D13S317", "D21S11", "D18S51", "TH01", "D5S818",
"FGA")))
ggplot(O, aes(x = P, y = M)) +
geom_density_ridges()

ggplot(O, aes(x=P, y=M, fill=P)) +


geom_density_ridges_gradient(scale = 3) +
theme_ridges() +
scale_y_discrete(expand = c(0.3, 0)) +
scale_x_continuous(expand = c(0.01, 0)) +
labs(x="P",y="M") +
ggtitle("P+M") +
theme(plot.title = element_text(hjust = 0.5))
library(viridis)
library(hrbrthemes)

ggplot(O, aes(x = P, y = M, fill = ..x..)) +


geom_density_ridges_gradient(scale = 1, rel_min_height = 0.01) +
scale_fill_viridis(name = "P", option = "H") +
labs(title = 'Temperatures in Lincoln NE in 2016') +
theme_ipsum() +
theme(
legend.position="none",
panel.spacing = unit(0.5, "lines"),
strip.text.x = element_text(size = 8)
)

ggplot(O, aes(y=M, x=P, fill=M)) +


geom_density_ridges(alpha=0.6, stat="binline", bins=20) +
theme_ridges() +
theme(
legend.position="none",
panel.spacing = unit(0.1, "lines"),
strip.text.x = element_text(size = 8)
) +
xlab("") +
ylab("Assigned Probability (%)")

You might also like