HES 505 Fall 2023: Session 6
Introduce literate programming
Describe pseudocode and its utility for designing an analysis
Introduce Quarto
as a means of documenting your work
Practice workflow
Science is a social process!!
Noise!!
Confirmation bias
Hindsight bias
Scripts: may make your code reproducible (but not your analysis)
Commenting and formatting can help!
Comments explain what the code is doing
Operations are ordered logically
Only relevant commands are presented
Useful object and function names
Script runs without errors (on your machine and someone else’s)
Scripts can document what you did, but not why you did it!
Scripts separate your analysis products from your report/manuscript
Let us change our traditional attitude to the construction of programs: Instead of imagining that our main task is to instruct a computer what to do, let us concentrate rather on explaining to human beings what we want a computer to do.
Documentation containing code (not vice versa!)
Direct connection between code and explanation
Convey meaning to humans rather than telling computer what to do!
Multiple “scales” possible
Your analysis scripts are computer software
Integrate math, figures, code, and narrative in one place
Explaining something helps you learn it
Outline your project
Write pseudocode
Identify potential packages
Borrow (and attribute) code from others (including yourself!)
An informal way of writing the ‘logic’ of your program
Balance between readability and precision
Avoid syntactic drift
A multi-language platform for developing reproducible documents
A ‘lab notebook’ for your analyses
Allows transparent, reproducible scientific reports and presentations
Metadata and global options: YAML
Text, figures, and tables: Markdown and LaTeX
Code: knitr
(or jupyter
if you’re into that sort of thing)
Allows you to set (or change) output format
Provide options that apply to the entire document
Spacing matters!
Basic formatting via Markdown
Fancier options using Divs and spans via Pandoc
Fenced Divs start and end with :::
(can be any number >3
but must match)
Use 3x ```
on each end
Include the engine {r}
(or python or Julia)
Include options beneath the “fence” using a hashpipe (#|
)
File locations and Quarto
Caching for slow operations
Modularizing code and functional programming