| 1 |
--- |
| 2 |
kernelspec: |
| 3 |
display_name: Python 2 |
| 4 |
language: python |
| 5 |
name: python2 |
| 6 |
--- |
| 7 |
|
| 8 |
# A notebook with R cells |
| 9 |
|
| 10 |
This notebook shows the use of R cells to generate plots |
| 11 |
|
| 12 |
```{code-cell} ipython2 |
| 13 |
%load_ext rpy2.ipython |
| 14 |
``` |
| 15 |
|
| 16 |
```{code-cell} ipython2 |
| 17 |
%%R |
| 18 |
suppressMessages(require(tidyverse)) |
| 19 |
``` |
| 20 |
|
| 21 |
```{code-cell} ipython2 |
| 22 |
%%R |
| 23 |
ggplot(iris, aes(x = Sepal.Length, y = Petal.Length, color=Species)) + geom_point() |
| 24 |
``` |
| 25 |
|
| 26 |
The default plot dimensions are not good for us, so we use the -w and -h parameters in %%R magic to set the plot size |
| 27 |
|
| 28 |
```{code-cell} ipython2 |
| 29 |
%%R -w 400 -h 240 |
| 30 |
ggplot(iris, aes(x = Sepal.Length, y = Petal.Length, color=Species)) + geom_point() |
| 31 |
``` |