1 | initial version |

If you start the Sage notebook, you can set the "system" of the notebook R by selecting "r" on the system dropdown. (The system dropdown is located toward the top of the screen in the notebook just to the right of the dropdown labeled "Data...". Initially, it will be set to "sage".)

Additionally, you can set the system of an individual cell to R by putting "%r" at the top of the cell.

When in R-mode, all of the commands that you enter into the notebook will be sent directly to a copy of R. For example, you can evaluate the following in the notebook:

```
a <- c(1,2,3);
a*2
```

to get the output

```
[1] 2 4 6
```

If you want to use R to do plotting in the notebook, then you need to use the PNG device. Here is some code that produces a basic plot:

```
png(file="myplot.png", bg="transparent")
plot(1:10)
rect(1, 5, 3, 7, col="white")
dev.off()
```

When R writes the image to a file, the notebook detects that a file has been created and displays it in the notebook.

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.