Professional Documents
Culture Documents
Analisis Eksplorasi Data
Analisis Eksplorasi Data
Analisis Eksplorasi Data
> library(ggplot2)
Warning message:
> theme_set(theme_bw())
> # plot
+ labs(title="Violin plot",
+ x="Class of Vehicle",y="Mileage") +
> library(ggplot2)
> theme_set(theme_classic())
+ labs(title="Density plot",
+ x="City Mileage",
+ fill="Number of Cylinders")
Mengubah jenis chart dengan menambahkan parameter posisi ke lapisan geometri untuk kepadatan
> library(ggplot2)
> theme_set(theme_classic())
+ labs(title="Density plot",
+ x="City Mileage",
+ fill="Number of Cylinders") +
+ scale_fill_manual(values=c("#dbdfe0", "#0faeb1",
+ "#0954b7", "#5c93b8"))
> #scale_fill_brewer(palette="Dark2")
ANDI FAHIRA ALSA 06211840000004 AED KELAS B
Pengenalan ggplot
> p + geom_violin()
+ geom_violin()
ANDI FAHIRA ALSA 06211840000004 AED KELAS B
> p + geom_violin()
> # Use a smaller bandwidth for closer density fit (default is 1).
> # Note that violins are automatically dodged when any aesthetic is
> # a factor
> if (require("ggplot2movies")) {
+ # number of outliers.
+ m + geom_violin()
ANDI FAHIRA ALSA 06211840000004 AED KELAS B
+ m + geom_violin() + scale_y_log10()
Pengenalan jitter
Jittered points
> p + geom_point()
ANDI FAHIRA ALSA 06211840000004 AED KELAS B
> p + geom_jitter()
Pendalaman jitter
Scatterplot Jittering
> set.seed(1)
Tutorial 3 graphics
Histogram pada R
> hist(SL)
> hist(SL[POP==1])
> hist(FINAREA[POP==5])
ANDI FAHIRA ALSA 06211840000004 AED KELAS B
> hist(SL[POP=="U.S.A”])
> hist(SL[POP == 1], xlab = “ body length for population 1”, main=”Size”)
> hist(SL[POP == 1], xlab = “ body length for population 1”, main=”Size”, col=2)
> hist(SL[POP == 1], xlab = “ body length for population 1”, main=”Size”, col=2,
density = 5)
Boxplot
> boxplot(SL[POP==1])
ANDI FAHIRA ALSA 06211840000004 AED KELAS B
> boxplot(SL~POP)
Scatter plot
> #scatter plot
> plot(FINAREA~TAREA)
> abline(lm(FINAREA~TAREA))
ANDI FAHIRA ALSA 06211840000004 AED KELAS B
[1] 1 2 3 4 5 6
> screen(1)
> hist(SL[POP==1])
> screen(2)
> hist(SL[POP==2])
> screen(3)
> hist(SL[POP==5])
> screen(4)
> screen(5)
> boxplot(SL[POP==2])
> screen(6)
> boxplot(SL[POP==5])
ANDI FAHIRA ALSA 06211840000004 AED KELAS B
> par(mfrow=c(1,3))
> hist(SL[POP==1])
> hist(SL[POP==2])
> hist(SL[POP==5])
ANDI FAHIRA ALSA 06211840000004 AED KELAS B
Exercise 1
> split.screen(fig=c(1,3));
[1] 1 2 3
> screen(1);
> boxplot(data1,xlab="population",ylab="range",col=5);
> screen(2);
> screen(3);
> boxplot(data1,xlab="population",ylab="range",col=7);
> close.screen(all=T);
ANDI FAHIRA ALSA 06211840000004 AED KELAS B
Exercise 2
> #exercise 2
> par(mfrow=c(2,3));
> boxplot(SL[POP==1],xlab="population",ylab="range",col=4);
> boxplot(SL[POP==2],xlab="population",ylab="range",col=5);
> boxplot(SL[POP==5],xlab="population",ylab="range",col=6);
> plot(TAREA[POP==1],FINAREA[POP==1],col=4);
> abline(lm(FINAREA[POP==1]~TAREA[POP==1]),col=4)
> plot(TAREA[POP==2],FINAREA[POP==2],col=5);
> abline(lm(FINAREA[POP==2]~TAREA[POP==2]),col=5)
> plot(TAREA[POP==5],FINAREA[POP==5],col=6);
> abline(lm(FINAREA[POP==5]~TAREA[POP==5]),col=6)
> close.screen(all=T);
ANDI FAHIRA ALSA 06211840000004 AED KELAS B