What We’ll Cover
- Productivity: Navigation and output tips
- Internals: How R Notebooks really work
- Ecosystem: Publishing, sharing, and version control
Basic familiarity with R Notebooks is presumed.
Notebook Recap
Notebook Recap
- Notebooks are R Markdown documents + new interaction model
- Code chunks are executed individually
- Code output appears beneath the chunk and is saved with the document
- Combines iterative approach with reproducible result
Navigation: Outline
Navigation: Jump To
Navigation: By Chunk
Navigation: Running
Output Management
Reproducibility
- Notebooks can be less reproducible than traditional R Markdown documents.
- Chunks can be run in any order.
- Chunks can access the global environment.
Simulating a Knit
Consistency
How R Notebooks Really Work
Publishing and Collaborating
Publishing
Two choices:
- Publish the notebook file directly (HTML)
- Render to a separate output format
Publishing: Notebook HTML
- Self-contained
- Compatible with any hosting service
- No viewer required
- Hydrates to full notebook (more on this later)
Publishing: RStudio Connect
- One-click publish inside your org
- Fine-grained access control
- Execute on the server
- Schedule executions
Collaborating: Plain Files
To: analyst@contoso.com
From: customer@northwind.com
I need some help with this analysis. Could you
take a look at what I have so far?
Thanks,
Charles
[ Attachment: foo.nb.html ]
Collaborating: Execution in Reverse
Collaborating: Opening Code in RStudio
Collaborating: Opening Notebook in RStudio
Collaborating: Open Inside RStudio
Collaborating: Open Notebook
Collaborating: Version Control #1
- Add
*.nb.html
to your .gitignore
or similar
- Check in only the
.Rmd
file
- All diffs are plain text
- Encourages reproducibility & independent verification of results
Collaborating: Version Control #2
- Check in the
.nb.html
file and the .Rmd
file
- Diffs are noisier
- RStudio loads outputs from
.nb.html
if newer
- Outputs and inputs are versioned together
- No need to re-execute lengthy or fragile computations
Versioned Output
When a notebook is opened:
- The local cache modified time is compared to the
.nb.html
- If
.nb.html
is older, it is ignored
- If
.nb.html
is newer, it replaces the local cache
- No merging or conflict management is performed!
The End