Obsidian and R workflow

Anyone else use R for data analysis?

Many of my notes deal with R code, statistical methods, and the subjects that I’m analyzing (environmental science). Theory, application, tips, and examples are interlinked, so Zettelkasten seems like a good approach for thinking through it. R also support a similar flavor of Markdown, complete with LaTeX math and folding, so Obsidian seems like a good fit for maintaining my knowledge base!

Going from Obsidian to R Studio, the only issues I’ve run into are

  • There needs be a blank line before headers, block quotes, bullet points, and lists, or they won’t render
  • Embedded images are supported ![caption](image.jpg), but you need to copy the images to the R project folder, and may need to edit the relative path if you’ve put them in a subfolder ![caption](images/image.jpg)
  • Double bracket links and hashtags can’t be used for navigation, but don’t break anything. Just need to do a search and replace to clean them up.
  • Transclusion won’t work
  • Footnotes are not supported

Going from R Studio to Obsidian

  • embedded images need to be copied to the attachments folder, and relative path corrected
  • Code blocks are a little harder to read without syntax highlighting
  • yaml header displays as a level 1 heading

For writing a report or academic paper, a possible workflow is to assemble an outline in Obsidian with relevant background info, citations, and some generic code snippets I think might come in handy. The results section would get fleshed out in R Studio, as I work with the data.

7 Likes

To answer your question, I use R quite a bit. But I’m still evaluating Obsidian.

One other point, I footnotes are allowed in Rmarkdown.^[See Sec. 2.5.1 in R Markdown: The Definitive Guide].

1 Like

hi comandra,

i’m also working in environmental science and also depend heavily on R for data analysis. i dug into the whole obsidian/zettelkasten universe earlier this year only.

i was wondering when reading your question about the file-links - are you separating your rstudio projects and your obsidian vault?

at the moment i’m doing so, but as the vault also contains information related to the project that the RStudio-Analysis is based in, I’m noticing more and more that the division of information of those two is not helpful for keeping the overview. my compromise at the moment looks like this: (semi-automatically) synchronizing my Rstudio-“Results/Plot”-folder to the Obisidian vault to make it possible to embed plots in notes with the proper file path.

1 Like

Hi everyone! I have also been struggling with this workflow and appreciate the comments. Paulge, I wonder if you have tried adding GitHub to the mix. This may sound cumbersome for those who are not familiar with Git and GitHub. However, as a novice, I can tell you it is easier to catch up than I thought. This is something that I’m trying right now and it seems to work:

  1. Create a repository in GitHub for your project (i.e. research paper).
  2. Install GitHub desktop to make a local copy of your repository on your computer.
  3. Create your “R Project” and link it to your repository using version control.
  4. Create (move a copy?) of your Obsidian Vault into the same local GitHub/R project folder.
  5. Start editing your obsidian notes in RStudio Or Obsidian and everything will be up to date.
  6. “Push” your changes into your repository.
  7. Your own ingredients to this recipe…

As I said, I’m testing this solution right now, and it passed the first test: Creating and editing notes alternatively in RStudio or Obsidian and being able to “Push” those changes to my repository in GitHub.

I haven’t tried these ones yet, but my hypotheses are:
You should not have to deal with relative paths for images.
The integration between Zotero, Better Bib Text, and R markdown should be seamless.

I’m curious about what could happen with code blocks. This is what I found in another forum: Handle (edit) other plain text file formats ( rmarkdown, tex, txt, code, etc ).

My plan is to use Obsidian for knowledge management (bibliography, etc) and knowledge exchange (network analyses) and keep the portions with code chunks as Rmd files.