Cargamos la BD “iris”
data("iris")
head(iris)
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 1 5.1 3.5 1.4 0.2 setosa
## 2 4.9 3.0 1.4 0.2 setosa
## 3 4.7 3.2 1.3 0.2 setosa
## 4 4.6 3.1 1.5 0.2 setosa
## 5 5.0 3.6 1.4 0.2 setosa
## 6 5.4 3.9 1.7 0.4 setosa
require(ggplot2)
## Loading required package: ggplot2
require(plotly)
## Loading required package: plotly
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
##Gráfico número 1:
g1=ggplot(data = iris,aes(x=Sepal.Length))
g1+geom_histogram()+theme_minimal()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
##Gráfico número 2:
g2=ggplot(data=iris, aes(x=Sepal.Length, y=Sepal.Width))
g2+geom_point()
##Gráfico número 3:
g3=ggplot(data=iris,aes(x=Sepal.Length, y=Sepal.Width,color=Species))
g3+geom_point()
##Gráfico número 4:
g4=ggplot(data=iris,aes(x=Sepal.Length, y=Sepal.Width,color=Species))
g5=g4+geom_point()+theme_minimal()+geom_smooth(method = "gam")
ggplotly(g5)
## `geom_smooth()` using formula 'y ~ s(x, bs = "cs")'
##Gráfico número 5:
p6=ggplot(data=iris,aes(x=Species, y=Sepal.Length,fill=Species))
p7=p6+geom_boxplot()
ggplotly(p7)