library(gridExtra)
# Membuat data frame
data <- data.frame(
Negara = c("Indonesia", "Filipina", "Thailand", "Singapore"),
Bidang = rep("Teknologi Informasi", 4),
Rentang_Umur = rep("20-30", 4),
Rata_Rata_Gaji = c(12.5, 6.8, 11, 86) # Dalam juta Rupiah
)
# Menampilkan data
print(data)
## Negara Bidang Rentang_Umur Rata_Rata_Gaji
## 1 Indonesia Teknologi Informasi 20-30 12.5
## 2 Filipina Teknologi Informasi 20-30 6.8
## 3 Thailand Teknologi Informasi 20-30 11.0
## 4 Singapore Teknologi Informasi 20-30 86.0
Visulisasi Pie Chart
pie_chart <- ggplot(data, aes(x = "", y = Rata_Rata_Gaji, fill = Negara)) +
geom_bar(stat = "identity", width = 1) +
coord_polar("y", start = 0) +
theme_void() +
labs(title = "Proporsi Gaji Rata-Rata per Negara") +
scale_fill_brewer(palette = "Set3")
pie_chart

Visulisasi Bar Chart
bar_chart <- ggplot(data, aes(x = Negara, y = Rata_Rata_Gaji, fill = Negara)) +
geom_bar(stat = "identity") +
theme_economist() +
labs(title = "Gaji Rata-Rata per Negara", x = "Negara", y = "Gaji (Juta Rupiah)") +
scale_fill_brewer(palette = "Set2")
bar_chart

Visulisasi Histogram
histogram <- ggplot(data, aes(x = Rata_Rata_Gaji)) +
geom_histogram(binwidth = 10, fill = "lightgreen", color = "black") +
theme_fivethirtyeight() +
labs(title = "Distribusi Gaji", x = "Gaji (Juta Rupiah)", y = "Frekuensi")
histogram

Visulisasi Density Plot
density_plot <- ggplot(data, aes(x = Rata_Rata_Gaji)) +
geom_density(fill = "lightblue", alpha = 0.5) +
theme_clean() +
labs(title = "Density Plot Gaji", x = "Gaji (Juta Rupiah)", y = "Density")
density_plot

Visulisasi Box Plot
box_plot <- ggplot(data, aes(y = Rata_Rata_Gaji)) +
geom_boxplot(fill = "orange", color = "black") +
theme_tufte() +
labs(title = "Box Plot Gaji", y = "Gaji (Juta Rupiah)")
box_plot

Semua Ditampilkan
grid.arrange(pie_chart, bar_chart, histogram, density_plot, box_plot, ncol = 2)

# Menghitung statistik deskriptif
mean_gaji <- mean(data$Rata_Rata_Gaji)
median_gaji <- median(data$Rata_Rata_Gaji)
q1_gaji <- quantile(data$Rata_Rata_Gaji, 0.25)
q3_gaji <- quantile(data$Rata_Rata_Gaji, 0.75)
range_gaji <- range(data$Rata_Rata_Gaji)
var_gaji <- var(data$Rata_Rata_Gaji)
sd_gaji <- sd(data$Rata_Rata_Gaji)
# Menampilkan hasil
cat("Mean:", mean_gaji, "\n")
## Mean: 29.075
cat("Median:", median_gaji, "\n")
## Median: 11.75
cat("Q1:", q1_gaji, "\n")
## Q1: 9.95
cat("Q3:", q3_gaji, "\n")
## Q3: 30.875
cat("Range:", range_gaji, "\n")
## Range: 6.8 86
cat("Varians:", var_gaji, "\n")
## Varians: 1446.023
cat("Standar Deviasi:", sd_gaji, "\n")
## Standar Deviasi: 38.0266