library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
## ✔ ggplot2 3.3.6 ✔ purrr 0.3.4
## ✔ tibble 3.1.8 ✔ dplyr 1.0.10
## ✔ tidyr 1.2.1 ✔ stringr 1.4.1
## ✔ readr 2.1.2 ✔ forcats 0.5.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
Making data frame
months <- c(10, 20, 50, 80)
learning <- c(30, 70, 40, 50)
df <- data.frame(months, learning)
df
Making the plot
ggplot(df, aes(x = months, y = learning)) +
geom_line(color = "purple") +
geom_point(color = "yellow", alpha = 0.5, size = 10) +
geom_point() +
ggtitle("Lemming Luck")
Making data frame
df <- tibble(
subject = c("Math", "Math", "Math", "Science", "Science", "Science"),
number = c(35, 15, 5, 50, 10, 0),
letter = c("A", "B", "C", "A", "B", "C")
)
df
Making the plot
ggplot(df) +
geom_col(aes(x = subject, y = number, fill = letter),
position = position_stack(reverse = TRUE)
) +
ggtitle("Grades")
Making vector
values <- c(
rep(6, 8),
rep(18.5, 9),
rep(33.5, 9),
55, 200,
rep(56.5, 5),
rep(109.76, 2)
)
values
## [1] 6.00 6.00 6.00 6.00 6.00 6.00 6.00 6.00 18.50 18.50
## [11] 18.50 18.50 18.50 18.50 18.50 18.50 18.50 33.50 33.50 33.50
## [21] 33.50 33.50 33.50 33.50 33.50 33.50 55.00 200.00 56.50 56.50
## [31] 56.50 56.50 56.50 109.76 109.76
Plotting
ggplot() +
geom_boxplot(aes(x = values, y = ""))
There are 2 outliers