Rtools is required to build R packages but is not currently installed - r

I am relatively new to R/RStudio. I was successfully able to install packages until today. Each time I try to install a package, I receive the following error:
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/
Installing package into ‘C:/Users/my. Name/Documents/R/win-library/3.6’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.6/openintro_1.7.1.zip'
Content type 'application/zip' length 3136068 bytes (3.0 MB)
downloaded 3.0 MB
Rtools is already installed on my machine, so I'm not sure why it's not being recognized.
I have tried un-installing and re-installing rtools but can't seem to resolve the issue. Any insight here would be greatly appreciated!

The message indicates RTools isn't installed properly. Download and install it like so:
Go here
Download rtools
Find the file that just downloaded
Double click on it to start installation
Close and reopen RStudio
Everything should work now!
A nice 2-minute video explainer can be found here.
Why is RTools necessary in the first place?
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 have installation problems
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.
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.

if your os is windows, you should install rtool to create a building env for some R packages.
full stack for install R Rstudio Rtool .
you can get answer from this video https://www.bilibili.com/video/BV1Mv411u7Cm?spm_id_from=333.999.0.0

Related

HOW can we create xlsx file and write xlsx file in R? [duplicate]

I am relatively new to R/RStudio. I was successfully able to install packages until today. Each time I try to install a package, I receive the following error:
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/
Installing package into ‘C:/Users/my. Name/Documents/R/win-library/3.6’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.6/openintro_1.7.1.zip'
Content type 'application/zip' length 3136068 bytes (3.0 MB)
downloaded 3.0 MB
Rtools is already installed on my machine, so I'm not sure why it's not being recognized.
I have tried un-installing and re-installing rtools but can't seem to resolve the issue. Any insight here would be greatly appreciated!
The message indicates RTools isn't installed properly. Download and install it like so:
Go here
Download rtools
Find the file that just downloaded
Double click on it to start installation
Close and reopen RStudio
Everything should work now!
A nice 2-minute video explainer can be found here.
Why is RTools necessary in the first place?
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 have installation problems
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.
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.
if your os is windows, you should install rtool to create a building env for some R packages.
full stack for install R Rstudio Rtool .
you can get answer from this video https://www.bilibili.com/video/BV1Mv411u7Cm?spm_id_from=333.999.0.0

Rtools 4.0 not found during package installation

For many R packages I try to install (on my Windows 10 machine), I get a warning:
> install.packages('rstan')
WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:
I thought this was just an erroneous error message since the installation seemed to proceed anyway, but recently I tried to install a package (rstan) and found it completely nonfunctional. My hunch is that since rstan relies completely on compiling code with rcpp, maybe I only got away with the previous packages because I wasn't using the functions in them that relied on Rtools.
I reinstalled Rtools 4.0, and devtools::find_rtools() returns TRUE. But when I run Sys.getenv()['PATH'] there is no Rtools on the path. There isn't a place in the installation process to tell it I want Rtools on the path either, so these instructions don't help - the menus they refer to don't exist for me. So I thought this might be an issue where the new Rtools 4.0 doesn't put itself on the system path. But the problem persisted even after I directly edited the Windows path environment variables (both system and user versions) to include the path given to me by pkgbuild::rtools_path() (C:\rtools40\usr\bin, a path which both exists and appears to be correct).
This doesn't seem to be the same problem as Rtools 4.0 (Rstudio falsely claims it was deleted), since there are no claims Rtools was deleted. It's also not the same as Rtools not being detected by R as far as I can tell: I'm not leaving any features out of my Rtools installation - I'm not even getting the option to in my install wizard.
Would appreciate any advice or recommendations.
Rtools40 requires that you add its bin directory to your PATH variable. The full instructions are here.
You can update your ~/.Renviron file with any of the following methods:
You can do that manually by opening ~/.Renviron and putting the following in it:
PATH="${RTOOLS40_HOME}\usr\bin;${PATH}"
You can also use R (Gui or RStudio or Shell) with the following:
writeLines(
'PATH="${RTOOLS40_HOME}\\usr\\bin;${PATH}"',
con = file("~/.Renviron", open = "a")
)
Both of these methods require a restart of R.

How to install MVPARTwrap package in R version 3.6.1?

I am trying to install mvpart and MVPARTwrap packages in R version 3.6.1.
I install on my PC the folder of these two packages in zip version and load them in the relative folder of the package.
When I run the script library(mvpart) I get this message:
ERROR: 'mvpart' package was built before R 3.0.0: please reinstall it."
I try to load this library in the old version of R (version 2.15) and the message is
in install.packages (mvpart): object 'mvpart' not found".
I do not understand why it is impossible to load this package. Thanks so much.
Maybe the answer is no more relevant, but I just had to install those libraries so maybe it will still help someone later. I suggest the install from github as it will install dependencies, you need however to be able to compile the source. So here we go :
first install rtools if it is not already installed go here and follow the instruction
update/install devtools if necessary as described here
using this command, it should work now. you may be asked to update some packages, accept all
devtools::install_github("cran/mvpart")

how to install/update a package from source inside cygwin

new to Cygwin. I downloaded apg-cyg and have been using it to install packages.
Recently I installed R and the current version in Cygwin packages is R.3.2.4. I wanted to install the latest R package but couldn't find a way from googling on how to do it inside Cygwin.
Is this possible to do or I just have to wait for the Cygwin packages updating their packages to the latest version? It would be nice to be able to update a package using the source file inside Cygwin..
Edit:
I should mention that I tried to install ggplot2 inside R using install.packages() and there was non-zero exit status and the installation couldn't go through.
You can install the source using cygwin setup. Click on the mouse on the "Src?" column.
The source will be installed in /usr/src
PS: next R release 3.3.1 is in 11 days. It will be packed for cygwin if there are no build issue
Followup:
There were several build issues, it took longer than expected to build 3.3.1
https://www.cygwin.com/ml/cygwin-announce/2016-06/msg00056.html

installed directory not writable, cannot update packages 'boot', 'class', 'KernSmooth', 'mgcv', 'nnet', 'rpart', 'spatial' [duplicate]

This question already has answers here:
installation path not writable R, unable to update packages
(9 answers)
Closed 2 years ago.
I installed the Bioconductor packages on R version 3.1.2 on Ubuntu 14.04 and received the message below:
The downloaded source packages are in
‘/tmp/RtmpZYw0Qp/downloaded_packages’ Warning message: installed
directory not writable, cannot update packages 'boot', 'class',
'KernSmooth', 'mgcv', 'nnet', 'rpart', 'spatial'
What does it mean, and how does it affect using the above packages on R?
I faced the same problem working in R-studio. The solution is to give root access to R.
In Windows, that means you need to run the program as an Administrator.
In Unix/Linux, you should launch R from the terminal by doing sudo R.
Then, once you're running with sufficient privileges, you can try installing your package and it should work.
The warning means that there are more recent versions of the listed packages available, but your version cannot be updated because the directory in which the packages are installed cannot be written to. Usually this means that R was installed with 'system administrator' privileges, but that you are trying to update packages as a regular user.
The consequence is that the features or bug fixes implemented in the updated packages are not available to you. The specific consequences could range from minor typographical corrections on a man page through serious bug fixes. Qualitatively, my bet is that it 'does not matter' for most uses.
The solution is to update these packages when running R as a user with permission to write to packages in the installed directories -- typically the last element of the output of .libPaths(), or more fine-grained via installed.packages()[, "LibPath"]
I faced the same problem today when installing three Bioconductor packages under Windows. Two (dependencies of the package I really wanted) were already on my system in newer forms (as described in #Martin-Morgan solution) and so no action was necessary. However, one was not installed. For this, third package, I had success in doing an installation from the local file that was downloaded during the failed install without having to escalate privileges (which was my next step as outlined by #Ninadmw).
In R, go to the menu Packages/Install Package(s) from local files and navigate to the local download directory listed, which in your case was /tmp/RtmpZYw0Qp/downloaded_packages, and select the package you want to install.
In RStudio (which you should use), go to the menu Tools\Install Packages, change the install from field to Package Archive File (.zip; .tar.gz), use Browse... to navigate to the listed download directory, which in your case was /tmp/RtmpZYw0Qp/downloaded_packages and select the package you want to install. Then click on the Install button.

Resources