-1

I need to install Rtools in order to work with keras package. I've successfully downloaded Rtools from https://cran.r-project.org/bin/windows/Rtools/, but then I need to "put it on a path", as it is stated here on this website. I don't understand what is written here about doing that. Could you,please, explain it to me in a simple way and, desirably, with an example?

Thank you for your help.

Maxim
  • 99
  • 1
  • 4
  • 11
  • See [adobe's guide](https://www.java.com/en/download/help/path.html) on how to extend the system path on windows machines. – Oliver Oct 02 '20 at 11:21

1 Answers1

2

The path is the list of all directories the operating system is going to look to find a program when you call it.
An alternative instead of modifying the system path, is to create a file which tells R where to find RTools.
As stated in the installation doc, just open an R console and execute once:

writeLines('PATH="${RTOOLS40_HOME}\\usr\\bin;${PATH}"', con = "~/.Renviron")
Waldi
  • 39,242
  • 6
  • 30
  • 78
  • writeLines('PATH="${RTOOLS40_HOME}\\usr\\bin;${PATH}"', con = "~/.Renviron") Should I paste it as is? Or should I change anything in this code line? – Maxim Oct 02 '20 at 12:11
  • just paste it as is, this is the easiest solution I know ;) – Waldi Oct 02 '20 at 12:14
  • **Now restart R, and verify that make can be found, which should show the path to your Rtools installation.** When I do this and then (in order to test) paste `Sys.which("make")` I get only `make ""` .In the example it is shown, that I should get something like ## **"C:\\rtools40\\usr\\bin\\make.exe"** – Maxim Oct 02 '20 at 12:34
  • 2
    Just try if RTools works, for example by compiling code : `Rcpp::cppFunction('int add(int x, int y) { int sum = x + y;return sum;}')` – Waldi Oct 02 '20 at 12:39
  • Ran this code, got the following: **There were 12 warnings (use warnings() to see them) Warning: In system(cmd) : 'make' not found Error in sourceCpp(code = code, env = env, rebuild = rebuild, cacheDir = cacheDir, : Error 1 occurred building shared library. WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding: https://cran.rstudio.com/bin/windows/Rtools/** – Maxim Oct 02 '20 at 14:14
  • Looks like RTools was indeed not correctly installed. If you are on Windows, do you confirm you can see `c:\rtools40` directory? – Waldi Oct 02 '20 at 14:22
  • Yes, I approve having such a directory (C:\rtools40). – Maxim Oct 02 '20 at 14:41
  • Did you restart R+RStudio? – Waldi Oct 02 '20 at 14:47
  • Ctrl+Shift+F10 = restarting R, right? How to restart RStudio? – Maxim Oct 02 '20 at 14:48
  • just close everything & restart – Waldi Oct 02 '20 at 14:57
  • Close RStudio itself? – Maxim Oct 02 '20 at 15:07
  • yes, close RStudio itself – Waldi Oct 02 '20 at 15:08
  • And what then to do? – Maxim Oct 02 '20 at 15:10
  • Restart & Try to compile again above code to see if Rtools is now found – Waldi Oct 02 '20 at 15:15
  • Well, `Rcpp::cppFunction('int add(int x, int y) { int sum = x + y;return sum;}')` compiled, but didn't give any result in console. – Maxim Oct 02 '20 at 15:20
  • RTools is working ;) try `add(1,2)` which you just compiled. So that other can benefit from our discussion, consider [accepting the answer](https://stackoverflow.com/help/someone-answers). – Waldi Oct 02 '20 at 15:27
  • I simply typed `add(1,2)` in console and got **3**. But how is it related to C++ in R and `cppFunction('int add(int x, int y) { int sum = x + y;return sum;}')`? – Maxim Oct 02 '20 at 15:32
  • Did you look at the content of what you compiled? You just created your first `add` function in C++, add isn't an R function – Waldi Oct 02 '20 at 15:35
  • I didn't pay enough attention to it :( . Now I understand. Thank you very much for your help and effort!!! – Maxim Oct 02 '20 at 15:46
  • @maxim glad I could help. Don't forget to [accept answers](https://stackoverflow.com/help/someone-answers) – Waldi Oct 02 '20 at 15:47
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/222413/discussion-between-maxim-and-waldi). – Maxim Oct 02 '20 at 16:04