Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
6 views
in R Programming by (7.3k points)
edited by

I am in the process of figuring out how to use my university cluster. It has 2 versions of R installed. System-wide R 2.11 (Debian 6.0) and R 2.14.2 in a non-standard location.

I am trying to use MPI together with snow. The code I am trying to run is the following

library(snow)

library(Rmpi)

cl <- makeMPIcluster(mpi.universe.size()-1)

stopCluster(cl)

mpi.quit()

It works without the problems on R 2.11. (I launch the script with mpirun -H localhost,n1,n2,n3,n4 -n 1 R --slave -f code.R). Now when I try to do it with R 2.14.2, I get the following message:

Error: This is R 2.11.1, package 'snow' needs >= 2.12.1

In addition: Warning message:

So it seems that R loads the package snow version compiled for R 2.11. I've installed snow under R 2.14 into my home folder and I added the following lines to my code:

libPaths("/soft/R/lib/R/library")

.libPaths("~/R/x86_64-pc-linux-gnu-library/2.11")

print(.libPaths())

print(sessionInfo())

print(version)

And the output before the error confirms that I am indeed running R 2.14.2 and my R packages folder is first in the search path. But I still get the error.

So my question is how do I determine which version of the package is loaded in R? I can see with installed. packages all the packages that are installed, so maybe there is some function that lists similar information for loaded packages?

2 Answers

0 votes
by
edited by

You can use the packageVersion() function to print version information about the loaded packages.

For example:

packageVersion('ggplot2')

Output:

[1] ‘3.2.0’

To print the version information about R, the OS and attached or loaded packages, use the sessionInfo() function.

sessionInfo()

0 votes
ago by (1.7k points)

# Define library path for R 2.14.2

.libPaths(" ~/R/x86_64-pc-linux-gnu-library/2.14 ")

# Load the snow package

library(snow)


 

# Check version

print(packageVersion("snow"))

# Print session info

print(sessionInfo())

To ensure if the snow package has been loaded into R, define the library path, and then load the library. By combining packageVersion() with sessionInfo() you can determine if a correct version of the snow package was loaded into R.

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...