A short description of the post.
So as a way to expand some of the analytical tools we offer the students at my work, I’m developing a version of my Data Literacy course that will use Python as well as R. There is a lot of overlap in these two languages and both are of interest to our students as they develop their toolkits. This document walks through how to set up Pweave on your machine so you can engage in a little Literate Programming (trust me, it will make your life suck a lot less. To see how to set up Atom, see my previous post.
I believe that the time is ripe for significantly better documentation of programs, and that we can best achieve this by considering programs to be works of literature. Hence, my title Literate Programming.
Knuth – 1992
If you think of it a bit, as data scientists, the documents and manuscripts we work on every day are just extensions of programs and scripts we use to do our work. However, in academia we are taught the process in entirely the wrong sequence. Traditionally, we are taught the following sequence.
The main problem is that any iteration of the manuscript would require manually going through the process or changing the text document, rerunning the analysis, then replotting the figures. Move this section up her and then go back through and make sure all your figure and table references are recovered.
But this is entirely upside-down! Instead of Communicate -> Analysis -> Visualize, our workflow should be more like:We should be data-focused, not manuscript focused!
The research manuscript is simply an advertisement of our research and the data, it IS NOT the research or data.
Dyer – Just now!
PWeave is like SWeave (and its better version Knitr) on R. It is a tool that we can use to interdigitate our analysis and how we go about presenting it all in one place. This allows us to have a single document where we can have the data, the analyses, the output, and the verbiage that we use to describe what we are doing. This tight coupling of the data to the rest of the components helps in Reproducible Research.
To install Pweave, you need to have atom and python already configured. Then in Atom, install the following packages
What this does is mix in markdown text and code. If you have not used Markdown before, it is pretty straight forward. Here are some simple rules.
All the python code must be within the bounds marked by the three backslashes. The code will be evaluated, from the top of the document to the bottom. You do not have to show the code for it to run.
To weave the document into HTML (we can do other formats as well but this gets us going, open the terminal and type:
pweave.exe test1.pmdAnd it should produce a document in the same folder but as an *.html file.
Which is pretty cool. Now, there are a lot more things you can do with markdown.
For attribution, please cite this work as
Dyer (2018, July 23). The Dyer Laboratory: Setting up Atom for Pweave Or What the what. Retrieved from https://dyerlab.github.io/DLabWebsite/posts/2018-07-23-setting-up-atom-for-pweave-or-what-the-what/
BibTeX citation
@misc{dyer2018setting, author = {Dyer, Rodney}, title = {The Dyer Laboratory: Setting up Atom for Pweave Or What the what}, url = {https://dyerlab.github.io/DLabWebsite/posts/2018-07-23-setting-up-atom-for-pweave-or-what-the-what/}, year = {2018} }