iris=read.csv("iris.csv")
iris
str(iris)
'data.frame': 150 obs. of 5 variables:
$ sepal.length: num 5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
$ sepal.width : num 3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ...
$ petal.length: num 1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ...
$ petal.width : num 0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
$ variety : chr "Setosa" "Setosa" "Setosa" "Setosa" ...
ggplot(iris,aes(y=sepal.length,x=variety,fill= variety))+geom_boxplot()
ggplot(iris,aes(x=sepal.length,y=sepal.width,color=variety))+geom_point()
theme_mininal()
Error in theme_mininal() : could not find function "theme_mininal"
ggplot(iris,aes(y=sepal.length,x=variety,fill=variety))+geom_violin ()
iris=read.csv("iris.csv")
iris
library(plotly)
plot_ly(data=iris,x=~sepal.length,y=~sepal.width,color=~variety,type="violin")
NA
`
plot_ly(data=iris,x=~sepal.length,y=~variety,type="box")
cor_mat=cor(iris[,1:4])
cor_mat
sepal.length sepal.width petal.length petal.width
sepal.length 1.0000000 -0.1175698 0.8717538 0.8179411
sepal.width -0.1175698 1.0000000 -0.4284401 -0.3661259
petal.length 0.8717538 -0.4284401 1.0000000 0.9628654
petal.width 0.8179411 -0.3661259 0.9628654 1.0000000
library(ggcorrplot)
ggcorrplot(cor_mat)
ggcorrplot(cor_mat,type="lower")
library(GGally)
Registered S3 method overwritten by 'GGally':
method from
+.gg ggplot2
ggpairs(iris,aes(color=variety))
library(stats)
iris_pca=prcomp(iris[,1:4],center=TRUE,scale=TRUE)
summary(iris_pca)
Importance of components:
PC1 PC2 PC3 PC4
Standard deviation 1.7084 0.9560 0.38309 0.14393
Proportion of Variance 0.7296 0.2285 0.03669 0.00518
Cumulative Proportion 0.7296 0.9581 0.99482 1.00000
pc_score=as.data.frame(iris_pca$x[,c(1,2)])
pc_score
pc_data=cbind(pc_score,variety=iris$variety)
pc_data