-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathREADME.Rmd
70 lines (51 loc) · 1.75 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
```
# ggpipe
*ggplot with the pipe*
This package wraps most `ggplot2` functions so they work with the pipe `%>%`
with [minimal overhead](http://rpubs.com/zeehio/ggpipe-overhead) (if noticeable).
[](https://travis-ci.org/zeehio/ggpipe)
[](https://cran.r-project.org/package=ggpipe)
## Installation
You can install ggpipe from github with:
```{r gh-installation, eval = FALSE}
# install.packages("devtools")
devtools::install_github("zeehio/ggpipe")
```
## Example
```{r,message=FALSE, fig.height=3, fig.width=3}
# as ggpipe wraps ggplot2 functions, do not use library(ggplot2) in your scripts
library(ggpipe)
ggplot(mtcars) %>%
geom_point(aes(x = mpg, y = disp))
```
This package provides an additional `unggplot()` function to get back the data
from the plot, so multiple plots could be generated on a single pipe:
```{r}
iris_sepal_png <- "README-iris_sepal.png"
iris_petal_png <- "README-iris_petal.png"
iris %>%
ggplot() %>%
geom_point(aes(x = Sepal.Length, y = Sepal.Width, color = Species)) %>%
ggsave(iris_sepal_png, height = 3, width = 5, dpi = 72) %>%
unggplot() %>%
ggplot() %>%
geom_point(aes(x = Petal.Length, y = Petal.Width, color = Species)) %>%
ggsave(iris_petal_png, height = 3, width = 5, dpi = 72) %>%
unggplot() %>%
head()
```
Plot the two figures:
```{r, fig.width=5, fig.height=3, dpi=72}
knitr::include_graphics(iris_sepal_png)
knitr::include_graphics(iris_petal_png)
```