Giter Club home page Giter Club logo

rmd2jupyter's Introduction

rmd2jupyter

Convert rmarkdown (.Rmd) files into jupyter notebooks (.ipynb).

Example

Create a .Rmd file.

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.

Rmd -> ipynb.

Now convert to an ipython notebook.

## 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.

rmd2jupyter's People

Contributors

mkearney avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

rmd2jupyter's Issues

Overwrites the original file

This project was very promising. But unfortunately it overwrites the original file. I wasn't in the mood to check if the notebook looked good...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.