Get the path of current script

In RStudio, you can get the path to the file currently shown in the source pane using rstudioapi::getSourceEditorContext()$path If you only want the directory, use dirname(rstudioapi::getSourceEditorContext()$path) If you want the name of the file that’s been run by source(filename), that’s a little harder. You need to look for the variable srcfile somewhere back in the … Read more

Understanding user file ownership in docker: how to avoid changing permissions of linked volumes

Two options I’ve found: CHOWN all the things (after doing your work) I’ve done docker run -v `pwd`/shared:/shared image, and the container has created files within pwd/shared that are how owned by the docker process. However, /shared is still owned by me. So within the docker process, I do chown -R `stat -c “%u:%g” /shared` … Read more

How to add table of contents in Rmarkdown?

The syntax is — title: “Sample Document” output: html_document: toc: true theme: united — in the documentation. Make sure this is at the beginning of your document. Also make sure your document actually has headers otherwise R can’t tell what you want in the table of contents.

Rtools not being detected by R

Turns out when I installed RTools I left out the R 2.15.x+ toolchain option in the installation, which lead to the gcc never being installed. Hopefully, this post will serve as a diagnostic guide if RStudio fails to register RTools. Thank you everyone for your help.

Split the title onto multiple lines?

Examples for adding an abtract show the use of pipes | to break lines and include paragraphs. This works as well for the title and other yaml elements. For an abstract or title: — abstract: | What works for the abstract. Works for the title, too! title: | | title | subtitle output: pdf_document —