Keep R, RTools, Packages and RStudio up to date

 

Keep Installr package up to date for the R development environment R, RTools, Packages and RStudio

To keep the programming language R, the packages and RStudio up to date, the package “installr”helps. This can be used to update installed components in the console.

With RTools it is possible to install packages from sources and create them yourself.With RTools it is possible to install packages from sources and create them yourself.

(Image: Joos / RStudio PBC)

To work with R, many developers use RStudio and use extensions in the form of”packages”. These components should be kept up-to-date, as should the programming language itself. The tools for creating your own packages should also be available on the computer and be updated regularly.

RTools allow you to create your own packages and install source packages. We show below how the components in the console can be checked and updated. We deal with R, RTools, RStudio and the associated packages.

RTools-Create your own packages with R

With RTools it is possible to install packages from sources and create them yourself.With RTools it is possible to install packages from sources and create them yourself.

(Image: Joos / RStudio PBC)

For working with packages, it makes sense that the RTools are installed. With RTools you can create your own packages. The installation of packages from sources is also possible with RTools.

To access the tools of the RTools package from RStudio, the commands in the rtools installation directory should be added to the path in Windows. To do this, the developers recommend a text file ” .Renviron“ with the content…

PATH="${RTOOLS40_HOME}usrbin;${PATH}"

… in the document directory. The entry can also be made directly in R and RStudio with the following command:

writeLines('PATH="${RTOOLS40_HOME}\usr\bin;${PATH}"', con = "~/.Renviron")

After restarting R and RStudio, the following command can be used to check whether the path is entered correctly:

Sys.which("make")

Here the path to the file ” make.exe”. Whether the tools work can be checked by installing a package from a source:

install.packages("jsonlite", type = "source")

Use Installr for updates

With the packageWith the package “installr” you can update R and the packages within RStudio.

(Image: Joos / RStudio PBC)

To keep R, Packages and RStudio up to date, the package “installr” is used. Although the processes can also be started manually, “installr” offers the advantage that in one operation R can be updated and all packages can be transferred to the new version. The update of the packages can also be done via this way. All steps can be confirmed individually, so that no unwanted actions are performed.

The necessary installr package is supplied with …

install.packages("installr")

… integrated into RStudio and then …

library(installr)

… enabled. After installation, the verification of the installed R-version can be displayed using:

updateR()

The window then shows the installed and the latest version of R. On request, the information page of the new R version can be displayed here and R can also be updated immediately. If R is current, the console displays the value “FALSE”.

Before updating R, the RStudio displays the message that the update should be done better in RGui and not in RStudio. This message can be confirmed with “no”. After that, the installation wizard starts and installs the new R version.

The successful update can be checked again with updateR (). Which version the RStudio should use in the future is controlled by “ToolsGlobal Options”. Here the new version must be selected manually, the process is not done automatically.

Apply and update packages to new R version

Update packages in a new installed R version.Update packages in a new installed R version.

(Image: Joos / RStudio PBC)

When R is updated via “installr”, a message appears to indicate whether the packages from the old version should be transferred to the new version. This message is confirmed with “Yes”. You can then select whether the packages in the old version should be preserved or deleted.

During this process, no update of the package packages takes place, here only the data are taken over, but remain available on request in the old version.

In general, it makes sense to keep the packages for a while to ensure that there are no problems. After taking over the packages, the packages can be updated via the wizard.

As part of the update, the RGui of the new version can also be called. Generally, the old R version should be uninstalled after some time. After restarting R, the new version should be displayed as the used version in RStudio if the version has been selected in the options.

In the console the installed Packages can be …

installed.packages()

… are displayed. Deprecated packages shows the console with:

old.packagesupdate.packages

… in turn updates packages that come from known sources when new versions are available. To be able to perform the update without user interaction, append the following prompt “ask = FALSE” in brackets:

update.packages(ask = FALSE)

If you only want to update your own package, you do this with “install.packages“, for example:

install.packages("plotly")

Update RStudio

Update RStudio.Update RStudio.

(Image: Joos / RStudio PBC)

RStudio can be updated either via the “installr” or via the menu item “HelpCheck for Updates”. With the function ” install.Rstudio () ” updates RStudio from the console. However, the function does not check whether the Version is already up to date, but always installed the new Version over the existing Version.

If not already available on the computer, the programming language R itself is also installed.If not already available on the computer, the programming language R itself is also installed.

(Image: Joos / RStudio PBC)

If you do not want to use” installr”, but rather want to update your environment manually, you have to perform the individual steps manually. First, the latest version of R is downloaded and installed by the developers. The packages can be manually copied from the old R directory to the new directory. The packages are located in the directory “library”.

(ID:46999846)

Ready to see us in action:

More To Explore

IWanta.tech
Logo
Enable registration in settings - general
Have any project in mind?

Contact us:

small_c_popup.png