#Saya akan membuat data Clear Time bos di Genshin Impact dengan reaction-reaction yang tersedia.

Membuat data dengan 5 kolom dan 5 Baris.

Reaction <- c(“Burgeon”, “HyperBloom”, “Freeze”, “Vaporize”, “Melt”)

Weapon_Level <- c(400,400,900,700, 850)

Elemental_Mastery <- c(700, 800, 200, 250, 300)

Character_Level <- c(900, 900,700, 700,750)

Clear_Time <- c(200,150, 300, 260, 350)

datacleartime <- data.frame(Reaction, Weapon_Level, Elemental_Mastery, Character_Level, Clear_Time)

print(datacleartime)

Reaction <- c("Burgeon", "HyperBloom", "Freeze", "Vaporize", "Melt") 

Weapon_Level <- c(400,400,900,700, 850) 

Elemental_Mastery <- c(700, 800, 200, 250, 300)

 Character_Level <- c(900, 900,700, 700,750) 

Clear_Time <- c(200,150, 300, 260, 350)

datacleartime <- data.frame(Reaction, Weapon_Level, Elemental_Mastery, Character_Level, Clear_Time)

print(datacleartime)
##     Reaction Weapon_Level Elemental_Mastery Character_Level Clear_Time
## 1    Burgeon          400               700             900        200
## 2 HyperBloom          400               800             900        150
## 3     Freeze          900               200             700        300
## 4   Vaporize          700               250             700        260
## 5       Melt          850               300             750        350

Eksplorasi Data

Membuat grafik boxplot untuk melihat sebaran data pada tiap peubah

library(viridisLite)

data.clear <- datacleartime [-1]

boxplot(data.clear, main=“Plot Boxplot”, col=viridis(5))

library(viridisLite)
## Warning: package 'viridisLite' was built under R version 4.3.2
data.clear <- datacleartime [-1] 

boxplot(data.clear, main="Plot Boxplot", col=viridis(5))

Membuat histogram dengan warna berbeda untuk setiap kategori reaction, histogram ini menampilkan cleartime.

library(ggplot2)

ggplot(datacleartime, aes(x = Clear_Time, fill = Reaction)) +

geom_histogram(binwidth = 20, position = “identity”, alpha = 0.6) +

labs(title = “Histogram Clear Time Berdasarkan Reaction”, x = “Clear Time”, y = “Frequency”) +

scale_fill_manual(values = c(“Burgeon” = “red”, “HyperBloom” = “blue”, “Freeze” = “green”, “Vaporize” = “purple”, “Melt” = “orange”))

library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.3.2
 ggplot(datacleartime, aes(x = Clear_Time, fill = Reaction)) + 

geom_histogram(binwidth = 20, position = "identity", alpha = 0.6) + 

labs(title = "Histogram Clear Time Berdasarkan Reaction", x = "Clear Time", y = "Frequency") + 

scale_fill_manual(values = c("Burgeon" = "red", "HyperBloom" = "blue", "Freeze" = "green", "Vaporize" = "purple", "Melt" = "orange"))

Korelasi

#Menghitung Korelasi

cor(data.clear)

library(ggplot2)

library(reshape2)

cor_matrix <- cor(data.clear)

melt_cor <- melt(cor_matrix)

ggplot(melt_cor, aes(Var1, Var2, fill = value)) +

geom_tile(color = “white”) +

scale_fill_gradient2(low = “green”, mid = “blue”, high = “red”, midpoint = 0,

name = “Korelasi”, limits = c(-1, 1)) +

labs(title = “Korelasi”,

x = “Peubah”,

y = “Peubah”) +

theme_minimal()

cor(data.clear)
##                   Weapon_Level Elemental_Mastery Character_Level Clear_Time
## Weapon_Level         1.0000000        -0.9456199      -0.9157015  0.9282425
## Elemental_Mastery   -0.9456199         1.0000000       0.9859322 -0.8732651
## Character_Level     -0.9157015         0.9859322       1.0000000 -0.7980155
## Clear_Time           0.9282425        -0.8732651      -0.7980155  1.0000000
library(ggplot2)
library(reshape2)
## Warning: package 'reshape2' was built under R version 4.3.2
cor_matrix <- cor(data.clear)
melt_cor <- melt(cor_matrix)

ggplot(melt_cor, aes(Var1, Var2, fill = value)) +
  geom_tile(color = "white") +
  scale_fill_gradient2(low = "green", mid = "blue", high = "red", midpoint = 0,
  name = "Korelasi", limits = c(-1, 1)) +
  labs(title = "Korelasi",
       x = "Peubah",
       y = "Peubah") +
  theme_minimal()

Scatter Plot

#Creating a scatter plot
plot(data.clear$Character_Level, data.clear$Clear_Time, main = "Scatter Plot", xlab = "Character_Level", ylab = "Clear_Time", col = "black")

#Buat Model Regresi Linearnya
lm_model <- lm(Clear_Time ~ Character_Level, data = data.clear)

#Tambahkan Garis ke scatter plot
abline(lm_model, col = "purple")