Last active
December 4, 2020 17:03
-
-
Save chendaniely/ece0cc5cd2324750461575fd1b9ab026 to your computer and use it in GitHub Desktop.
Altair in Rmd
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: "rmd altair" | |
output: html_document | |
--- | |
```{r setup, include=FALSE} | |
knitr::opts_chunk$set(echo = TRUE) | |
library(reticulate) | |
reticulate::use_condaenv() | |
reticulate::py_config() | |
``` | |
```{python} | |
import altair as alt | |
from vega_datasets import data | |
chart = alt.Chart(data.cars.url).mark_point().encode( | |
x='Horsepower:Q', | |
y='Miles_per_Gallon:Q', | |
color='Origin:N' | |
) | |
``` | |
```{python} | |
type(chart) | |
``` | |
```{python} | |
chart.save('chart.html') | |
``` | |
<iframe src="chart.html"></iframe> | |
```{r} | |
htmltools::includeHTML("chart.html") | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment