title: Link Project and R Version
body: <p>I have two different versions of R installed, one which is up to date and which I use for all my regular R coding (needs to be up to date so that I can use various updated and new packages) and one which I use to access OLAP cubes (needs to be the R Client from Microsoft, because this is the only one which supports the <code>olapR</code> package, and which currently uses R version 3.4.3). </p>
  
  <p>Since, in theory, I only have to access the OLAP cube once a month, I "outsourced" this task to a different RStudio project, in which I download and save the required data for all other projects. Hence, all other projects never require the <code>olapR</code> package to be installed and can and will be run in the up to date R version.</p>
  
  <p>Now, ideally I would like to link my R version to my projects, so that I do not have to change my global R version and restart RStudio every time I access the OLAP cube or work on this data retrieval project (and then switch it back). However, I could not find any options in RStudio to achieve this result.</p>
  
  <p>There are a few threads out there describing the same problem, but with no satisfactory answer in my opinion:</p>
  
  <p><a href="https://support.rstudio.com/hc/en-us/community/posts/200657296-Link-Project-and-R-Version" rel="nofollow noreferrer">https://support.rstudio.com/hc/en-us/community/posts/200657296-Link-Project-and-R-Version</a></p>
  
  <p><a href="https://stackoverflow.com/questions/46771608/rstudio-project-using-different-version-of-r">Rstudio project using different version of R</a></p>
  
  <p>I also tried looking for a different package than <code>olapR</code> but with similar functionality, but could not find anything except X4R, which seems outdated and does not work for me (<a href="https://github.com/overcoil/X4R" rel="nofollow noreferrer">https://github.com/overcoil/X4R</a>). Sadly, I am also unable to directly access the databases which the OLAP cube uses for its results, so I cannot go "around" it.</p>
  
  <p>I am happy for any help or suggestions you can offer, whether it is a general workaround to link a project to a specific R version or the (less helpful for the community) solution of accessing the OLAP cube in a different way.</p>
  
  <p>Thanks in advance!</p>
  
  <hr>
  
  <hr>
  
  <p>Using the answer from MrGumble I created a .bat file that will execute my .R file using the desired R installation. Even though it is not the answer I thought I would get, I think it is an even better solution to the problem.</p>
  
  <p>For all facing a similar issue, here is the .bat file (never created one before, so also had to google how to do it and I guess some might be in the same position):</p>
  
  <pre><code>@echo off
  title Getting data for further processing in R
  echo Retrieving OLAP data
  echo. 
  "C:\Program Files\Microsoft\R Client\R_SERVER\bin\Rscript.exe" "C:\Users\me\Documents\Projects\!Data\script.R"
  echo. 
  echo Saved data
  echo. 
  pause
  </code></pre>
  
  <p>Thanks again to MrGumble for his help.</p>