This content is from the fall 2016 version of this course. Please go here for the most recent version.
If you want to use Python for your final project and integrate a Jupyter Notebook into the website, you can use a shell script to convert the .ipynb
files to Markdown (.md
) files. Create a file called render.sh
in your main repository directory and add this to it:
#!/bin/bash
# convert jupyter notebooks to markdown
for notebook in $( ls *.ipynb ); do
/Users/$USER/anaconda/bin/jupyter nbconvert --to markdown $notebook
done
# render_site using rmarkdown
Rscript -e 'rmarkdown::render_site()'
You can execute this file from the shell or within R Studio (in the script editor pane you will see a button to “Run Script”). This file does two things:
for
loop (written in Bash) that finds all Jupyter Notebook files (ls *.ipynb
) in the top-level directory of the repo and converts them to Markdown documents. The Markdown files will have the same names as the original files but end in .md
.rmarkdown::render_site()
not only renders .Rmd
files, but it will also convert .md
to .html
. This allows the Python content to be rendered natively in the website.This work is licensed under the CC BY-NC 4.0 Creative Commons License.