Created
December 12, 2016 03:54
-
-
Save rizkidoank/e3fc558cc3c01b1f966cc59aae09fffb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#load data | |
data(iris) | |
#struktur dataset | |
str(iris) | |
#menampilkan beberapa data teratas | |
head(iris) | |
#membuat variabel iris.num untuk data numerik | |
iris.num <- iris[,1:4] | |
#statistika deskriptif | |
summary(iris) | |
#variansi atribut numerik | |
var(iris.num) | |
#membuat pie chart spesies | |
pie(table(iris$Species)) | |
#mengatur layout 2x2, dengan outer margin 1 | |
par(mfrow=c(2,2),oma=c(1,1,1,1)) | |
#membuat histogram tiap atribut | |
hist(iris$Sepal.Length,col = "grey") | |
hist(iris$Sepal.Width,col = "grey") | |
hist(iris$Petal.Length,col = "grey") | |
hist(iris$Petal.Width,col = "grey") | |
#mengatur layout 2x2, dengan margin 2 | |
par(mfrow=c(2,2),mar=c(2,2,2,2)) | |
#membuat boxplot atribut terhadap spesies | |
boxplot(Sepal.Length ~ Species, main = "Box Plot Sepal Length - Species", data = iris, xlab = "Species", ylab = "Sepal.Length") | |
boxplot(Sepal.Width ~ Species, main = "Box Plot Sepal Width - Species", data = iris, xlab = "Species", ylab = "Sepal.Width") | |
boxplot(Petal.Length ~ Species, main = "Box Plot Petal Length - Species", data = iris, xlab = "Species", ylab = "Petal.Length") | |
boxplot(Petal.Length ~ Species, main = "Box Plot Petal Width - Species", data = iris, xlab = "Species", ylab = "Petal.Width") | |
#membuat pairs plot | |
iris.jitter <- apply(iris.num,2,function(o){jitter(o)}) | |
pairs(iris.jitter,main="Pairs Plot of Iris Data",pch=21,bg = c("red", "green", "blue")[unclass(iris$Species)]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment