Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Discover all installed R packages with a Java dependency (for security reasons)

For security reasons I am forced to de-install Java (JRE) on a machine I am using with R.

How can I (easily :-) discover all installed packages that use Java?

Edit 14.12.2021: The log4j-log4shell-cve-2021-44228-vulnerability makes this question (and answers) even more interesting ;-)

like image 535
R Yoda Avatar asked Nov 30 '17 21:11

R Yoda


People also ask

How do I see what packages are installed in R?

To see what packages are installed, use the installed. packages() command. This will return a matrix with a row for each package that has been installed.

Do you need Java for R?

It looks like the answer is yes. If you go to a package's canonical page on CRAN, its SystemRequirements: should be listed. Since Java (>= 7.0) is on there, it's required for the package to work. Yes, you need to install java the install 'rJava' from R studio, then install 'tabulizerjars' !

How do you get documentation of an installed and loaded R package?

Besides finding the DESCRIPTION files such as cran.r-project.org or stat.ethz.ch, you can also access the description file inside R with the command packageDescription("package") , via the documentation of the package help(package = "package") , or online in the repository of the package.

What are the dependencies of R packages?

R packages have dependency packages that must be installed and loaded in order for the desired package to be used. Check out my sample R code below to print all dependencies for a certain package and install all of them.

How do I install an R package from CRAN?

To install an R package from CRAN, we can use the install.packages () function: Here, we’ve installed the readr R package used for reading data from the files of different types: comma-separated values (CSV), tab-separated values (TSV), fixed-width files, etc. Make sure that the name of the package is in quotation marks.

How to audit the installed R packages for security vulnerabilities?

We can audit the installed R packages for security vulnerabilities via the command Which produces the output As the output suggests, this function performs a few steps: Calls installed.packages () to determine the installed packages on your machine. Although there are warnings about this taking a little while, I’ve never had any issues.

Why do we need to install R packages?

R is a powerhouse programming language with many data science applications. But before we can put its packages to work, we need to install them. Here’s how. R is a programming language for statistical computing, especially efficient for performing data science tasks.


1 Answers

You can use installed.packages to determine which packages import the rJava package. You need to tell installed.packages to include the Imports field from the package description, and then check which packages import rJava.

LIBS = installed.packages(fields=c("Imports"))
JPacks = grep("Java", LIBS[,"Imports"], ignore.case=TRUE)
LIBS[JPacks, c("Package", "Imports")]
          Package    
RWeka     "RWeka"    
RWekajars "RWekajars"
          Imports                                                                
RWeka     "RWekajars (>= 3.9.0), rJava (>= 0.6-3), graphics, stats,\nutils, grid"
RWekajars "rJava (>= 0.6-3)"
like image 159
G5W Avatar answered Sep 24 '22 04:09

G5W