Creating R Package, Warning: Package '---' Was Built Under R Version 3.1.2

Creating R package, Warning: package ‘---’ was built under R version 3.1.2

Those are warnings, not errors, which means you can proceed but it's better if you address them.

In this case, you're getting the warnings because a few of the packages you need were built using an R version that is newer than the R version you are running. This can potentially be a problem, though it's likely not a problem, hence it's just a warning. If any of those packages have a different behaviour in the newer R version, for example, this would be critical, though that's likely not the case.

I would suggest updating your R version to 3.1.2, and that would get rid of these warnings plus you'll have a newer R version :) If you are working in an environment where you cannot update R, then it's fine, you can go on with your package with these warnings, it's just non-ideal.

warning messages when developing R package

The reason for this is, as the message says, that you are using different libraries built under different versions of R. This could mean that it could break at some point due to version differences and R is letting you know this. To solve this you could update your packages to the most recent version. This can be done manually by running:

update.packages()

or if you want to update them all:

update.packages(ask=FALSE)

To update one specific "PACKAGE"

install.packages("PACKAGE")

although this might take some time and some packages might not be available up to the same version. You could use devtools to install an specific VERSION of the PACKAGE

require(devtools)
install_version("PACKAGE", version = "VERSION", repos = "http://cran.us.r-project.org")

If you do not want to do this you can suppress the warning message by using:

suppressWarnings()

or set warning messages off (might not be a good idea):

options(warn = -1)

use

options(warn = 0)

to set them on again.

?warning

for help.

Why am I getting an error while trying to load caret package?

I think you can try two things. One is updating your R version (and Rstudio version?). The other can be updating ggplot2 with dependencies:

install.packages('ggplot2', dependencies = TRUE)

How to find the R version under which an R package was built?

The information you want is in the last column ("Built") of the output of installed.packages(), per https://stat.ethz.ch/R-manual/R-devel/library/utils/html/installed.packages.html.

.libPaths() # get the library location
installed.packages(lib.loc = "C://Revolution//R-Enterprise-7.3//R-3.1.1//library")

Remove warnings of package dependency with R CMD check

That's likely your R version is out of date: the R version used (3.2.4) to build these packages is ahead of yours, and so a warning is returned.

You can check your current version either in the preamble when you launch a new session or by typing R.version.

Most of the time it has no practical consequences (for small gaps between R versions), but: i) the function you use may have been affected by version change and ii) it's a good idea to have the last R stable version.

Gain Package Installation error in R 3.1.2

I believe that the problem lies in your corrupted, incomplete or otherwise incorrect R environment. I was able to install that package without any problems at all just by issuing the default command:

> install.packages("gains")
Installing package into ‘C:/Users/Alex/Documents/R/win-library/3.1’
(as ‘lib’ is unspecified)
trying URL 'http://cran.rstudio.com/bin/windows/contrib/3.1/gains_1.1.zip'
Content type 'application/zip' length 35802 bytes (34 Kb)
opened URL
downloaded 34 Kb

package ‘gains’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
C:\Users\Alex\AppData\Local\Temp\RtmpSSRths\downloaded_packages
> sessionInfo()
R version 3.1.1 (2014-07-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] stats graphics grDevices utils datasets methods
[7] base

loaded via a namespace (and not attached):
[1] tools_3.1.1

As a quick solution to the problem, I suggest to specify CRAN mirror explicitly:

install.packages("gains", repos = "http://cran.rstudio.com")

How should I deal with package 'xxx' is not available (for R version x.y.z) warning?

1. You can't spell

The first thing to test is have you spelled the name of the package correctly? Package names are case sensitive in R.


2. You didn't look in the right repository

Next, you should check to see if the package is available. Type

setRepositories()

See also ?setRepositories.

To see which repositories R will look in for your package, and optionally select some additional ones. At the very least, you will usually want CRAN to be selected, and CRAN (extras) if you use Windows, and the Bioc* repositories if you do any biological analyses.

To permanently change this, add a line like setRepositories(ind = c(1:6, 8)) to your Rprofile.site file.


3. The package is not in the repositories you selected

Return all the available packages using

ap <- available.packages()

See also Names of R's available packages, ?available.packages.

Since this is a large matrix, you may wish to use the data viewer to examine it. Alternatively, you can quickly check to see if the package is available by testing against the row names.

View(ap)
"foobarbaz" %in% rownames(ap)

Alternatively, the list of available packages can be seen in a browser for CRAN, CRAN (extras), Bioconductor, R-forge, RForge, and GitHub.

Another possible warnings message you may get when interacting with CRAN mirrors is:

Warning: unable to access index for repository

Which may indicate the selected CRAN repository is currently be unavailable. You can select a different mirror with chooseCRANmirror() and try the installation again.


There are several reasons why a package may not be available.


4. You don't want a package

Perhaps you don't really want a package. It is common to be confused about the difference between a package and a library, or a package and a dataset.

A package is a standardized collection of material extending R, e.g. providing code, data, or documentation. A library is a place (directory) where R knows to find packages it can use

To see available datasets, type

data()

5. R or Bioconductor is out of date

It may have a dependency on a more recent version of R (or one of the packages that it imports/depends upon does). Look at

ap["foobarbaz", "Depends"]

and consider updating your R installation to the current version. On Windows, this is most easily done via the installr package.

library(installr)
updateR()

(Of course, you may need to install.packages("installr") first.)

Equivalently for Bioconductor packages, you may need to update your Bioconductor installation.

source("http://bioconductor.org/biocLite.R")
biocLite("BiocUpgrade")

6. The package is out of date

It may have been archived (if it is no longer maintained and no longer passes R CMD check tests).

In this case, you can load an old version of the package using install_version()

library(remotes)
install_version("foobarbaz", "0.1.2")

An alternative is to install from the GitHub CRAN mirror.

library(remotes)
install_github("cran/foobarbaz")

7. There is no Windows/OS X/Linux binary

It may not have a Windows binary due to requiring additional software that CRAN does not have. Additionally, some packages are available only via the sources for some or all platforms. In this case, there may be a version in the CRAN (extras) repository (see setRepositories above).

If the package requires compiling code (e.g. C, C++, FORTRAN) then on Windows install Rtools or on OS X install the developer tools accompanying XCode, and install the source version of the package via:

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

# Or equivalently, for Bioconductor packages:
source("http://bioconductor.org/biocLite.R")
biocLite("foobarbaz", type = "source")

On CRAN, you can tell if you'll need special tools to build the package from source by looking at the NeedsCompilation flag in the description.


8. The package is on GitHub/Bitbucket/Gitorious

It may have a repository on GitHub/Bitbucket/Gitorious. These packages require the remotes package to install.

library(remotes)
install_github("packageauthor/foobarbaz")
install_bitbucket("packageauthor/foobarbaz")
install_gitorious("packageauthor/foobarbaz")

(As with installr, you may need to install.packages("remotes") first.)


9. There is no source version of the package

Although the binary version of your package is available, the source version is not. You can turn off this check by setting

options(install.packages.check.source = "no")

as described in this SO answer by imanuelc and the Details section of ?install.packages.


10. The package is in a non-standard repository

Your package is in a non-standard repository (e.g. Rbbg). Assuming that it is reasonably compliant with CRAN standards, you can still download it using install.packages; you just have to specify the repository URL.

install.packages("Rbbg", repos = "http://r.findata.org")

RHIPE on the other hand isn't in a CRAN-like repository and has its own installation instructions.

Changes in install.packages() from R 3.1.2 to R 3.2.1

I have found the problem.
The R 3.2.1 NEWS section (https://cran.r-project.org/src/base/NEWS) says

  • The default for option pkgType on platforms using binary packages is now "both", so source packages will be tried if binary versions
    are not available or not up to date.

The problem is that RStudio does not directly call install.packages but via a few other functions such as .rs.callAs. In one of these functions, available.packages() gets called without any arguments. So it determines the argument type via getOption("pkgType"). But since R 3.2.1 this is now "both" and not "win.binary" as in R 3.1.2.

A quick workaround for the problem is thus to add

options(pkgType="win.binary")

to the yourRinstallpath/etc/Rprofile.site



Related Topics



Leave a reply



Submit