
Briefly, you can get started by entering these commands in a terminal with working directory where you will place your file. If you need to set up Python in the directory from which this will be run, you can follow the instructions provided by RStudio at. Later, I’ll provide some additional information in case you want to run this from an R console without RStudio. I’m using HTML output here but PDF output is also supported just change the 5th line is this file. In RStudio, when you click the Knit button a document will be generated that includes both text and the output of any embedded R code chunks or Python code chunks within the document. There is enough flexibility that, as you get used to it, you can expand to include tables, figures, LaTeX equations, superscripts, subscripts, bold or italic formatting, various headers, and much more. However, most of the text can be entered quite simply without much special formatting, so you don’t need the RStudio editor – any editor will work. RStudio provides additional web-based information at this URL. This is a very easy language to learn and use, and RStudio in particular provides good help windows to remind users of the basics. They can also be used together, passing variables from R code to Python code and from Python code to R code, so the structure is quite flexible.

I’m going to construct this note using both R and Python, but that’s not necessary. Also, “R Markdown” is much easier to use than LaTeX, used in. With the greater emphasis on Python at NCAR, some may find this a good approach to simple documentation tasks. The intent of this note is to illustrate that and provide a template that others might find useful. The new aspect that I learned recently is that either RStudio or “knitr” also supports Python code, so that enables new ways of combining calculations and documentation. I have been using R in RStudio for this purpose, with an R package called “knitr” that supports interleaving code segments and text in a single document. I recently learned of a very useful approach to documenting data-analysis projects in order to improve “reproducibility” of the results, which enables someone else to repeat, check and extend the results.
