Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mkearney/rmd2jupyter
Convert Rmd (rmarkdown) to ipynb (Jupyter notebook)
https://github.com/mkearney/rmd2jupyter
ipynb-notebook jupyter-notebook python python-notebook r rmarkdown rmd rstats
Last synced: 27 days ago
JSON representation
Convert Rmd (rmarkdown) to ipynb (Jupyter notebook)
- Host: GitHub
- URL: https://github.com/mkearney/rmd2jupyter
- Owner: mkearney
- Created: 2018-01-08T17:42:08.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-01-08T23:17:16.000Z (almost 7 years ago)
- Last Synced: 2024-09-28T23:43:27.945Z (about 1 month ago)
- Topics: ipynb-notebook, jupyter-notebook, python, python-notebook, r, rmarkdown, rmd, rstats
- Language: R
- Size: 167 KB
- Stars: 23
- Watchers: 3
- Forks: 7
- Open Issues: 1
-
Metadata Files:
- Readme: README.Rmd
Awesome Lists containing this project
README
---
output: github_document
---```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, eval = FALSE)
```## rmd2jupyter
Convert rmarkdown (.Rmd) files into jupyter notebooks (.ipynb).
### Example
Create a .Rmd file.
```{r rmd}
rmd <- "# Module 1. Working with web APIs## Gathering publicly available web data
The two most common ways to collect publicly available web data are (1) web scraping and (2) interacting with Application Program Interfaces (API).
## Web scraping
- A normal workflow goes something like this
- Extract website source code, known as Extensible Markup Language (XML). XML is similar to HTML only designed for storing not displaying data.
- Although XML trees contain elements, tags, and text, data collected via web scraping is almost always unstructred### Web scraping in R
- I recommend the {rvest} package.\`\`\`{r}
library(rvest)## population statistics
population_url <- \"https://en.wikipedia.org/wiki/List_of_countries_by_population_(United_Nations)\"## read in page
pop <- read_html(population_url)
\`\`\`"## save as temp file
tmp <- tempfile(fileext = ".Rmd")
cat(rmd, file = tmp)## render html
rmarkdown::render(tmp)## output output
browseURL(gsub("\\.Rmd$", ".html", tmp))
```#### Rmd -> html
Screen capture of output.
![](tools/readme/ss_rmd.png)
#### Rmd -> ipynb.
Now convert to an ipython notebook.
```{r}
## install and load rmd2jupyter
devtools::install_github("mkearney/rmd2jupyter")
library(rmd2jupyter)## convert
rmd2jupyter(tmp)## open via your jupyter notebook method
```Screen capture of jupyter notebook.
![](tools/readme/ss_ipynb.png)