-
Notifications
You must be signed in to change notification settings - Fork 0
/
.Rhistory
41 lines (41 loc) · 2.21 KB
/
.Rhistory
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
fakultas <- c("Bisnis", "D3 Perhotelan", "ICT", "Ilmu Komunikasi", "Seni dan Desain")
jumlah_mahasiswa <- c(260, 28, 284, 465, 735)
akreditasi <- c("A","A","B","A","A")
info_mahasiswa <- data.frame(fakultas, jumlah_mahasiswa, akreditasi)
info_mahasiswa
library("ggplot2")
gambar <- ggplot(info_mahasiswa, aes(x=fakultas, y=jumlah_mahasiswa, fill=fakultas))
gambar <- gambar + geom_bar(width=1, stat="identity")
gambar
gambar <- gambar + ggtitle("Jumlah Mahasiswa per Fakultas")
gambar <- gambar + xlab("Nama Fakultas
gambar <- gambar + xlab("Nama Fakultas)
gambar <- gambar + xlab("Nama Fakultas")
gambar <- gambar + ylab("Jumlah Mahasiswa")
gambar
summarybyfakultas <- aggregate(x=mahasiswa$JUMLAH, by=list(Kategori=mahasiswa$Fakultas, Tahun=mahasiswa$ANGKATAN), FUN=sum)
library(ggplot2)
library(openxlsx)
install.packages(openxlsx)
install.packages("openxlsx")
library(openxlsx)
mahasiswa <- read.xlsx("mahasiswa.xlsx",sheet = "Sheet 1")
summarybyfakultas <- aggregate(x=mahasiswa$JUMLAH, by=list(Kategori=mahasiswa$Fakultas, Tahun=mahasiswa$ANGKATAN), FUN=sum)
summarybyfakultas <- setNames(summarybyfakultas, c("fakultas","tahun", "jumlah_mahasiswa"))
summarybyfakultas
summarybyfakultas$tahun = as.factor(summarybyfakultas$tahun)
ggplot(summarybyfakultas, aes(x=fakultas, y=jumlah_mahasiswa)) +
geom_bar(stat = "identity", aes(fill = tahun), width=0.8, position = position_dodge(width=0.8)) +
theme_classic()
piechart<- ggplot(summarybyfakultas, aes(x="", y=jumlah_mahasiswa, fill=fakultas))+ geom_bar(width = 1, stat = "identity")
piechart <- piechart + coord_polar("y", start=0)
piechart <- piechart + ggtitle("Disribusi Mahasiswa per Fakultas")
piechart <- piechart + scale_fill_brewer(palette="Blues")+ theme_minimal()
piechart <- piechart + guides(fill=guide_legend(title="Fakultas"))
piechart <- piechart + ylab("Jumlah Mahasiswa")
piechart
summarybyfakultas[summarybyfakultas$fakultas %in% c("ICT", "Ilmu Komunikasi"),]
ggplot(summarybyfakultas[summarybyfakultas$fakultas %in% c("ICT", "Ilmu Komunikasi"),], aes(x=fakultas, y=jumlah_mahasiswa)) +
geom_bar(stat = "identity", aes(fill = tahun), width=0.8, position = position_dodge(width=0.8)) +
theme_classic()
save.image("E:/Learn DqLab/Learn_Chart,Plot_Pie/Learn/Learn Pie Chart dan Plot.RData")