#collapse-hide suppressPackageStartupMessages(library(tidyverse)) theme_set(theme_minimal(base_size = 20)) # Abaikan kompleksitas kode dalam membuat term-nya, saya sedang latihan R df <- tibble( term = head( sort(c(outer( paste(2013:2017, 2014:2018, sep = "/"), c('term 1', 'term 2'), FUN = paste, sep = "\n" ))), -1 ), mean_year = c(4, 4.5, 4.03, 4.06, 4.14, 4.21, 4.03, 4.5, 4.4), gpa = c(3.41, 3.32, 3.51, 3.53, 3.41, 3.45, 3.42, 3.25, 3.34) ) par(mfrow = c(2, 1)) with(df, { barplot( mean_year ~ term, main = 'Length of Study', xlab = 'Graduation year', ylab = 'Year to graduate' ) barplot( gpa ~ term, main = "Average Graduates' GPA", xlab = "Graduation year", ylab = "GPA" ) }) #collapse-hide options(repr.plot.width = 13, repr.plot.height = 8, repr.plot.res = 100) df %>% rename( GPA = gpa, `Year to graduate` = mean_year ) %>% pivot_longer(-(term)) %>% ggplot(aes(group = 1)) + geom_line(aes(x = term, y = value), size = 1) + labs(x = "Graduation year", y = "") + facet_grid(name ~ ., scales = 'free_y') + theme_classic(base_size = 20)