Skip to content

Commit 61d13c8

Browse files
committed
added %>% option to googleVis + modified ggplot example for Plotly section {as.factor(offering)}
1 parent 41691f1 commit 61d13c8

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

9_DEVDATAPROD/Developing Data Products Course Notes HTML.Rmd

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,13 @@ n1$show("inline", include_assets = TRUE, cdn = F)
388388
- [documentation](http://cran.r-project.org/web/packages/googleVis/googleVis.pdf)
389389
- [plot gallery](https://developers.google.com/chart/interactive/docs/gallery)
390390
- [FAQ](https://developers.google.com/chart/interactive/faq)
391+
* can use the pipe operator from magrittr: `mtcars %>% ggvis(~mpg, ~wt, fill = ~ as.factor(am)) %>% layer_points() %>% layer_smooths()`
391392

393+
```{r, echo=F}
394+
suppressPackageStartupMessages(library(magrittr))
395+
suppressPackageStartupMessages(library(ggvis))
396+
mtcars %>% ggvis(~mpg, ~wt, fill = ~ as.factor(am)) %>% layer_points() %>% layer_smooths()
397+
```
392398

393399

394400
### Example (line chart)
@@ -469,7 +475,7 @@ library(plotly); library(ggplot2)
469475
# load data
470476
load("courseraData.rda")
471477
# bar plot using ggplot2
472-
g <- ggplot(myData, aes(y = enrollment, x = class, fill = offering))
478+
g <- ggplot(myData, aes(y = enrollment, x = class, fill = as.factor(offering)))
473479
g <- g + geom_bar(stat = "identity")
474480
g
475481
# initiate plotly object

9_DEVDATAPROD/Developing Data Products Course Notes.Rmd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ $\pagebreak$
390390
- [documentation](http://cran.r-project.org/web/packages/googleVis/googleVis.pdf)
391391
- [plot gallery](https://developers.google.com/chart/interactive/docs/gallery)
392392
- [FAQ](https://developers.google.com/chart/interactive/faq)
393+
* can use the pipe operator from magrittr: `mtcars %>% ggvis(~mpg, ~wt, fill = ~ as.factor(am)) %>% layer_points() %>% layer_smooths()`
393394

394395
$\pagebreak$
395396

0 commit comments

Comments
 (0)