library(esquisse)
library(ggplot2)
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ lubridate 1.9.4 ✔ tibble 3.2.1
## ✔ purrr 1.0.4 ✔ tidyr 1.3.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(tidymodels)
## ── Attaching packages ────────────────────────────────────── tidymodels 1.2.0 ──
## ✔ broom 1.0.7 ✔ rsample 1.2.1
## ✔ dials 1.3.0 ✔ tune 1.2.1
## ✔ infer 1.0.7 ✔ workflows 1.1.4
## ✔ modeldata 1.4.0 ✔ workflowsets 1.1.0
## ✔ parsnip 1.2.1 ✔ yardstick 1.3.2
## ✔ recipes 1.1.0
## ── Conflicts ───────────────────────────────────────── tidymodels_conflicts() ──
## ✖ scales::discard() masks purrr::discard()
## ✖ dplyr::filter() masks stats::filter()
## ✖ recipes::fixed() masks stringr::fixed()
## ✖ dplyr::lag() masks stats::lag()
## ✖ yardstick::spec() masks readr::spec()
## ✖ recipes::step() masks stats::step()
## • Use suppressPackageStartupMessages() to eliminate package startup messages
Reading File
data_calories <- read.csv("C:/Users/lenovo/OneDrive/ドキュメント/Visdat/Tugas 1/calories.csv")
data_climate <- read.csv("C:/Users/lenovo/OneDrive/ドキュメント/Visdat/Tugas 1/DailyDelhiClimateTest.csv")
data_climate$date <- as.Date(data_climate$date)
str(data_climate)
## 'data.frame': 114 obs. of 5 variables:
## $ date : Date, format: "2017-01-01" "2017-01-02" ...
## $ meantemp : num 15.9 18.5 17.1 18.7 18.4 ...
## $ humidity : num 85.9 77.2 81.9 70 74.9 ...
## $ wind_speed : num 2.74 2.89 4.02 4.54 3.3 ...
## $ meanpressure: num 59 1018 1018 1016 1014 ...
Visualisasi Data dengan Esquisse
#esquisse::esquisser("data_calories")
#esquisse::esquisser("data_climate")
Visualisasi Data Distribusi (Histogram)
ggplot(data_calories) +
aes(x = Calories) +
geom_histogram(bins = 30L, fill = "pink", color = "black", linewidth = 0.7) +
geom_vline(aes(xintercept = mean(Calories)), color = "blue", linetype = "dashed", linewidth = 1) +
labs(title = "Prediksi Kalori yang Terbakar Akibat Olahraga",
x = "Jumlah Kalori (Cal)",
y = "Frekuensi") +
theme_minimal() +
theme(plot.title = element_text(hjust = 0.5),
axis.title.x = element_text(size = 12),
axis.title.y = element_text(size = 12))

Visualisasi Data Time Series (Line Chart)
ggplot(data_climate) +
aes(x = date, y = humidity) +
geom_line(colour = "#957dad", linewidth = 0.5) +
labs(title = "Perubahan Kelembapan Tahun 2017 di Delhi",
x = "Bulan (2017)",
y = "Kelembapan (gr/m³)") +
theme_minimal() +
theme(plot.title = element_text(hjust = 0.5, size = 14, face = "bold"),
axis.title.x = element_text(size = 10),
axis.title.y = element_text(size = 10),
axis.text = element_text(size = 10))
