'Compiling RMarkdown with RStudio: why reading .RProfile?

Why RStudio, when compiling an .HTML from .Rmd, tries to read my .RProfile file?

I mean, I press the "Knit HTML" button, and then it actually tries to execute everything I have in .RProfile, loads every library mentioned there and then fails trying to source external files (I have a bunch of self-coded functions mentioned in .RProfile, lines like source('/Users/me/.rstudio-desktop/lib/lib.stocks.R'), etc.

For now, I literally have to move .RProfile out from the home directory during the compilation (knitting), but there probably should be some kind of option, or something?

Would be grateful for any suggestion :).


OS X 10.8.5, RStudio Version 0.98.1091



Solution 1:[1]

I'm new to using projects in RStudio, so educate me if I'm misunderstanding the question or doing something dumb. But it sounds like the issue is really that your .Rprofile is unnecessarily large for the specific document.

If you create a new project for a given document, they'll have their own .Rprofiles, which can be tailored to the needs of the doc.

More specifically, I made a template that I just copy/paste for each new project I start. It's just a folder that looks like this:

Project Template (folder)

  • Data (folder)
  • Scripts (folder)
  • Outputs (folder)
  • Documentation (folder) New Project.Rproj .Rprofile

The .Rprofile includes tidyverse and other packages I always use, to which I add other packages as required. Of course, if you're working on a large project that requires lots of large and/or homemade packages and you're just trying to make one small document within that project, you'll run into that problem again.

I'm sure you've solved this problem ages ago, but I hope this helps out anyone who (like me) came across this page while troubleshooting.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Alexander F. Wall