In this exploration, you are asked to
library("ggplot2")
N <- 1000
a <- 1
b <- 32
data <- runif(N, a, b) #generate 1000 random variables from 1 to 32 and labels it 'data'
df <- data.frame(data) #stores the data as a data table
#creates a box plot
ggplot(df, aes(y = data)) +
coord_flip() +
geom_boxplot() +
labs(title = paste0("Uniform Distribution U(", a, ",", b, ")"),
subtitle = "boxplot",
caption = "Humberto Flores") +
theme(axis.text.y = element_blank(),
axis.ticks.y = element_blank(),
panel.background = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank()) +
ylim(0,50) #defines the horizontal axis range from 0 to 50 for the box plot
#creates uniform distribution graph
ggplot(df, aes(x = data)) +
geom_density(kernel = "gaussian") +
labs(title = paste0("Uniform Distribution U(", a, ",", b, ")"),
subtitle = "density plot",
caption = "Humberto Flores") +
theme(panel.background = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank()) +
xlim(0,50)
N <- 1000
a <- 3
b <- 30
data <- runif(N, a, b) #generate 1000 random variables from 0 to 50 and labels it 'data'
df <- data.frame(data) #stores the data as a data table
#creates a box plot
ggplot(df, aes(y = data)) +
coord_flip() +
geom_boxplot() +
labs(title = paste0("Uniform Distribution U(", a, ",", b, ")"),
subtitle = "boxplot",
caption = "Humberto Flores") +
theme(axis.text.y = element_blank(),
axis.ticks.y = element_blank(),
panel.background = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank()) +
ylim(0,50) #defines the horizontal axis range from 0 to 50 for the box plot
#creates uniform distribution graph
ggplot(df, aes(x = data)) +
geom_density(kernel = "gaussian") +
labs(title = paste0("Uniform Distribution U(", a, ",", b, ")"),
subtitle = "density plot",
caption = "Humberto Flores") +
theme(panel.background = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank()) +
xlim(0,50)
rnorm command).N <- 1000
mu <- 25
sd <- 3
data <- rnorm(N, mu, sd)
df <- data.frame(data)
ggplot(df, aes(y = data)) +
coord_flip() +
geom_boxplot() +
labs(title = paste0("Normal Distribution N(", mu, ",", sd*sd, ")"),
subtitle = "boxplot",
caption = "Humberto Flores") +
theme(axis.text.y = element_blank(),
axis.ticks.y = element_blank(),
panel.background = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank()) +
ylim(0,50)
ggplot(df, aes(x = data)) +
geom_density(kernel = "gaussian") +
labs(title = paste0("Normal Distribution N(", mu, ",", sd*sd, ")"),
subtitle = "density plot",
caption = "Humberto Flores") +
theme(panel.background = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank()) +
xlim(0,50)
N <- 1000
mu <- 25
sd <- 2
data <- rnorm(N, mu, sd)
df <- data.frame(data)
ggplot(df, aes(y = data)) +
coord_flip() +
geom_boxplot() +
labs(title = paste0("Normal Distribution N(", mu, ",", sd*sd, ")"),
subtitle = "boxplot",
caption = "Math 32") +
theme(axis.text.y = element_blank(),
axis.ticks.y = element_blank(),
panel.background = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank()) +
ylim(0,50)
ggplot(df, aes(x = data)) +
geom_density(kernel = "gaussian") +
labs(title = paste0("Normal Distribution N(", mu, ",", sd*sd, ")"),
subtitle = "density plot",
caption = "Humberto Flores") +
theme(panel.background = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank()) +
xlim(0,50)
rexp command).N <- 1000
mu <- 32
m <- 1/32
data <- rexp(N, m)
df <- data.frame(data)
ggplot(df, aes(y = data)) +
coord_flip() +
geom_boxplot() +
labs(title = paste0("Exponential Distribution E(1/", mu, ")"),
subtitle = "boxplot",
caption = "Humberto Flores") +
theme(axis.text.y = element_blank(),
axis.ticks.y = element_blank(),
panel.background = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank()) +
ylim(0,250)
ggplot(df, aes(x = data)) +
geom_density(kernel = "gaussian") +
labs(title = paste0("Exponential Distribution E(1/", mu, ")"),
subtitle = "density plot",
caption = "Humberto Flores") +
theme(panel.background = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank()) +
xlim(0,250)
N <- 1000
mu <- 30
m <- 1/mu
data <- rexp(N, m)
df <- data.frame(data)
ggplot(df, aes(y = data)) +
coord_flip() +
geom_boxplot() +
labs(title = paste0("Exponential Distribution E(1/", mu, ")"),
subtitle = "boxplot",
caption = "Humberto Flores") +
theme(axis.text.y = element_blank(),
axis.ticks.y = element_blank(),
panel.background = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank()) +
ylim(0,250)
## Warning: Removed 1 rows containing non-finite values (stat_boxplot).
ggplot(df, aes(x = data)) +
geom_density(kernel = "gaussian") +
labs(title = paste0("Exponential Distribution E(1/", mu, ")"),
subtitle = "density plot",
caption = "Humberto Flores") +
theme(panel.background = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank()) +
xlim(0,250)
## Warning: Removed 1 rows containing non-finite values (stat_density).
Verify that you have 12 graphs in total (6 boxplots and 6 density plots), and replace “Math 32” with your full name in all of the graphs.
Finally, knit your work as either an HTML or PDF document, and upload that document back into the CatCourses assignment.