Beberapa Librari yang perlu diinstal sebagai berikut:
library(ggplot2)
library(readxl)
library(ggthemes)
library(gridExtra)
Data diinput dari Microsoft Excel dengan syntax seagai berikut:
data <- read_excel("D:/Document/Code_Project/R/Working_Directory/data_tren_penggunaan_ai.xlsx")
dari data terebut akan disajikan visualisasi data dalam bentuk Pie Chart. Berikut terlampir hasil visualisasi data persentase responden berdasarkan distribusi industri:
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(),
plot.title = element_text(hjust = 0.5, size = 14),
legend.position = "right")
pie_chart
## 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") +
theme(plot.title = element_text(hjust = 0.5, size = 14))
bar_chart
## 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 = "Lama Bekerja vs. Efisiensi Sebelum AI",
x = "Lama Bekerja (tahun)",
y = "Efisiensi Sebelum AI") +
theme(plot.title = element_text(hjust = 0.5, size = 14))
dot_plot
## Steam 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
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") +
theme(plot.title = element_text(hjust = 0.5, size = 12))
histogram
## Box Plot
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",
x = "",
y = "Lama Bekerja (tahun)",
fill = "Kondisi") +
theme(plot.title = element_text(hjust = 0.5, size = 14),
legend.position = "bottom")
boxplot_data
## 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") +
theme(plot.title = element_text(hjust = 0.5, size = 14),
legend.position = "bottom")
density_plot
## Menampilkan Semua Plot
grid.arrange(
pie_chart,
bar_chart,
dot_plot,
histogram,
boxplot_data,
density_plot,
ncol = 2,
heights = c(1, 1, 1)
)