Skip to content

Instantly share code, notes, and snippets.

@slopp
Created October 3, 2016 17:03
Show Gist options
  • Save slopp/52f0b170b61c2963deb055077fbbda48 to your computer and use it in GitHub Desktop.
Save slopp/52f0b170b61c2963deb055077fbbda48 to your computer and use it in GitHub Desktop.
---
output:
html_notebook: null
html_document: null
---
```{r setup}
library(ggplot2)
library(plotly)
library(dplyr)
library(RSQLite)
```
## In-Line Preview
You can now execute R code in-line and see a preview `r Sys.Date()` (Just place the cursor on the in-line code and hit CMD (ctrl) + Enter)
You can preivew LaTex in the same way: $y = \frac{1}{x}$
## Gallery View and Satellite Chunks
If a code chunk generates more than one output they are displayed across thumbnails:
```{r}
ggplot(mtcars, aes(x=hp, y=mpg)) + geom_point() + geom_smooth()
p <- ggplot(mtcars, aes(x=hp, y=mpg)) + geom_point(aes(colour = as.factor(cyl))) + geom_smooth()
p
ggplotly(p)
```
## Tabular Output
By default, printing tabular results (like `data.frame`) will create an interactive table:
```{r}
iris
```
## Multiple Language Support
You can insert chunks for different language types through the Insert Chunk UI
The chunk settings for different languages has been improved and includes defining the engine path. You can run different versions of languages by defining the install location in `engine.path`:
```{python, engine.path="/usr/bin/python2.7"}
import sys
print(sys.version)
```
```{python, engine.path="/usr/bin/python3"}
import sys
print(sys.version)
```
One of the newly supported languages is SQL:
First, create a db in R:
```{r}
d <- datasetsDb()
```
```{sql connection=d}
SELECT * FROM iris
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment