If you haven't done so already, download and install Rtools
This will solve the problem 90% of the time:
- Go to this site
- Download rtools
- Find the file that just downloaded
- Double click on it to start installation
- Close and reopen RStudio
- Everything should work now!
Background info
The reason this is necessary is because:
Rtools is a collection of software you need to be able to call R from the command line on Windows. You need to be able to call R from the command line to build and install packages from source code. Most packages will also require the program pdflatex.
If you already downloaded and installed Rtools, but still have problems
If you already followed the instructions above, but it still says not found, it may help to:
- Re-install R. Try to stick to the default installation settings if possible. Don't forget to close all current R sessions before reinstalling, then start a new R session and see if it works as expected. If not, try downloading and installing Rtools as outlined at the top of this answer; hopefully it installs as expected now.
Other possible causes of problems:
- Make sure your anti-virus software isn't preventing it being installed. Anti virus software can sometimes mistake it for something harmful and quarantine it.
- When reinstalling R, or when installing Rtools manually, be careful to look for any indication that you do not have write permissions to the drive you're installing to. If you don't have permission to install certain things, that may be what's causing Rtools to not install correctly. This is more likely to happen if there are multiple users on your Windows computer, or if your organisation has strict policies about what can be installed. To look into this, figure out where Rtools is being installed to, and ensure you have the ability to write to that folder.