R Markdown Presentation / Presentacion en RMarkdown
library(ggplot2)
library(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
data <- diamonds[sample(nrow(diamonds), 2000,),]
## sample from diamonds data from ggplot2 / Muestra de la base diamonds de ggplot2
summary(data)
## carat cut color clarity depth
## Min. :0.2300 Fair : 62 D:253 SI1 :494 Min. :55.80
## 1st Qu.:0.4000 Good :182 E:387 VS2 :465 1st Qu.:61.10
## Median :0.7000 Very Good:440 F:346 SI2 :332 Median :61.80
## Mean :0.7944 Premium :501 G:445 VS1 :301 Mean :61.76
## 3rd Qu.:1.0200 Ideal :815 H:278 VVS2 :180 3rd Qu.:62.60
## Max. :3.6500 I:201 VVS1 :130 Max. :79.00
## J: 90 (Other): 98
## table price x y z
## Min. :50.1 Min. : 353.0 Min. :0.000 Min. :0.00 Min. :0.00
## 1st Qu.:56.0 1st Qu.: 941.5 1st Qu.:4.710 1st Qu.:4.71 1st Qu.:2.90
## Median :57.0 Median : 2385.5 Median :5.690 Median :5.70 Median :3.52
## Mean :57.4 Mean : 3940.5 Mean :5.718 Mean :5.72 Mean :3.53
## 3rd Qu.:59.0 3rd Qu.: 5276.8 3rd Qu.:6.490 3rd Qu.:6.50 3rd Qu.:4.02
## Max. :73.0 Max. :18777.0 Max. :9.530 Max. :9.48 Max. :6.38
##
grafico <- ggplot(data = data, aes(x = carat, y = price, color=cut)) + geom_smooth(alpha=.1, size=1) + labs(x="Carat", y="Price")
ggplotly(grafico , originalData = FALSE)
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'