# Install dan load library
library(ggplot2)
library(readxl)
library(ggthemes)
library(gridExtra)
# Import Data
setwd("D:/coding/R")
data <- read_excel("data_tren_penggunaan_ai.xlsx")
head(data)
# Import Data
setwd("D:/coding/R")
data <- read_excel("data_tren_penggunaan_ai.xlsx")
head(data)
# 1. Pie Chart
pie_chart <- ggplot(data, aes(x = "", fill = Industri)) +
geom_bar(width = 1) +
coord_polar("y", start = 0) +
theme_minimal() +
labs(title = "Distribusi Industri") +
theme(axis.text.x = element_blank())
pie_chart

# 2. Bar Chart
bar_chart <- ggplot(data, aes(x = `Tingkat Penggunaan AI`, fill = `Tingkat Penggunaan AI`)) +
geom_bar() +
theme_minimal() +
labs(title = "Distribusi Tingkat Penggunaan AI", x = "Tingkat Penggunaan AI", y = "Frekuensi")
bar_chart

# 3. Dot Plot
dot_plot <- ggplot(data, aes(x = `Lama Bekerja (tahun)`, y = `Efisiensi Kerja Sebelum AI`)) +
geom_point(color = "blue", size = 2) +
theme_minimal() +
labs(title = "Dot Plot: Lama Bekerja vs. Efisiensi Sebelum AI", x = "Lama Bekerja (tahun)", y = "Efisiensi Sebelum AI")
dot_plot

# 4. Stem and Leaf Plot
stem(data$`Lama Bekerja (tahun)`)
##
## The decimal point is 1 digit(s) to the right of the |
##
## 0 | 11123344
## 0 | 5778889
## 1 | 4
## 1 | 7889
## 2 | 011233444
## 2 | 9
# 5. Histogram
histogram <- ggplot(data, aes(x = `Frekuensi Penggunaan AI per Minggu`)) +
geom_histogram(binwidth = 5, fill = "blue", color = "black", alpha = 0.7) +
theme_minimal() +
labs(title = "Histogram: Frekuensi Penggunaan AI per Minggu", x = "Frekuensi", y = "Jumlah Individu")
histogram

# 6. Boxplot
boxplot_data <- ggplot(data) +
geom_boxplot(aes(y = `Lama Bekerja (tahun)`, fill = "lama bekerja (tahun"), alpha = 0.6) +
theme_minimal() +
labs(title = "Boxplot: Lama Bekerja dalam tahun", fill = "Kondisi")
boxplot_data

# 7. Density Plot
density_plot <- ggplot(data, aes(x = `Efisiensi Kerja Sesudah AI`,fill = "Efisiensi")) +
geom_density(alpha = 0.5) +
theme_minimal() +
labs(title = "Density Plot: Efisiensi Kerja Sesudah AI", x = "Efisiensi", y = "Density")
density_plot

# Menampilkan semua plot
grid.arrange(pie_chart, bar_chart, dot_plot, histogram, boxplot_data, density_plot, ncol = 2)
