how to install install.packages("prob") in Jupyter notebook - r

I wanted to use Jupyter Notebook to do my homework. But when I put install.packages("prob") in Jupyter Notebook, it gave me this error:
Warning message:
“package ‘prob’ is not available (for R version 3.4.2)”
when I typed library(prob), it said no package called 'prob'
Error in library(prob): there is no package called ‘prob’
Traceback:
library(prob)
stop(txt, domain = NA)
anyone knows how to fix this problem? I would be very appreciate it.
Thank you so much.

The reason you can't install that package is exactly what it says it is :)
"Warning message: "package 'prob' is not available (for R version 3.4.2)"
If you look up the package on CRAN it will tell you:
Package ‘prob’ was removed from the CRAN repository.
Formerly available versions can be obtained from the archive.
Archived on 2017-09-11 as it depends on 'fAsianOptions', which was archived.
As that says, there are archived versions. But, to be clear, you'll need an archived version of 'fAsianOptions' as well.
To install an archived package, use:
archived_package = "a character vector with a URL or path to file you've downloaded"
install.packages(pkg = archived_package, repos = NULL)
I'd advise downloading the file yourself and then using the character vector of a path to that file as your pkg argument, unless you're familiar with the various quirks of downloading a file as part of a call to a function.

Related

How to Install mlr3extralearners in R?

So I am going to do some survivalsvm process and I need the mlr3extralearners package from GitHub. When I tried to install it locally using the tar.gz file, it said
Execution halted
Warning in install.packages: installation of package had non-zero exit status
I also tried to use the zip file, and it said
install.packages("C:/Users/Ivan/Downloads/mlr3extralearners-0.5.49.zip", repos = NULL, type = "win.binary", lib="C:/R-4.2.1/library")
then nothing happened.
I also tried using devtools::install_github("mlr-org/mlr3extralearners"), but the output was the same when I used the tar.gz file. When I checked in my library, I already have the mlr3extralearners package, but when I call it using library(mlr3extralearners), it does not work. Does anyone know how to solve this? Any help is appreciated.
https://rdrr.io/github/mlr-org/mlr3extralearners/
I believe this should work for you:
Install the latest version of this package by entering the following in R:
install.packages("remotes")
remotes::install_github("mlr-org/mlr3extralearners")

Failing to install panelr package

I am failing to read in the panelr package from the library. I used the package utilising its wbm() function on some panel data earlier this year and I have even tried to install it and I get this message: Warning in install.packages : package ‘panelr’ is not available (for R version 3.6.3).
Has the package been removed? Kindly assist on how I can install it or the new version of it.
If we want a specific version, use the versions package
install.packages('versions')
Then use
library(versions)
install.versions('panelr', '0.7.3')
If that version is not available in the MRAN repo, check the available versions with
available.versions('panelr')
If there are no versions available, then it returns an error. In that case, an option is to download the archived tar file from https://cran.r-project.org/src/contrib/Archive/panelr/ and then use install.packages to with source = TRUE
install.packages('path/to/.../...tar.gz', source = TRUE, repos = NULL)
Regarding your other question: Yes, it seems as it has been removed.

unable to access index for repository in R

I am on Windows 7 and I am using R Studio 0.99.902 with R3.3.1. When I am trying to install a package I get the Warnings:
Warning: unable to access index for repository http://cran.rstudio.com/src/contrib:
cannot open URL 'http://cran.rstudio.com/src/contrib/PACKAGES'
Warning: unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/src/contrib:
cannot open URL 'http://www.stats.ox.ac.uk/pub/RWin/src/contrib/PACKAGES'
It is the first time I see it and I cannot solve it. Can anyone help me ?
This issue is likely caused by the package being too old or too new for your R version. For example, if a package is released during R-3.4.1, it will not be available for R-3.3.1. Packages which are removed from CRAN before your R version are also not available. The package DESCRIPTION file shows if there is a hard restriction on which R versions the package will run.
Search for the package's CRAN page and see its status. You may still be able to install the package by downloading the package source (the tar.gz file) and in RStudio selecting Install from: Package Archive File in the Tools/Install Packages... menu (or using install.packages with repos = NULL). Beware that the package is not available from CRAN for a reason; you may need to make some changes to the package for it to work correctly.
Running options(download.file.method="libcurl") then installing packages did the trick for me. You may find an answer here.
Please note that compiling from source for Windows requires the appropriate version of Rtools that is compatible with the R version you are working with. This list is available at the Rtools site:
https://cran.r-project.org/src/contrib/Archive/
If compilation from source is complicated, it is also possible to find the Windows-compiled binaries (.zip files) for older versions of R at:
https://cran-archive.r-project.org/bin/windows/contrib
This link is referenced by the ReadMe file available at the "regular" repository for Windows binaries for different versions of R, namely at:
https://cran.r-project.org/bin/windows/contrib
Once the zip file is downloaded, you can run the following R code line to install the package:
# Use repos=NULL so that the first argument is a path to the local zip file
# containing the binary package to install
# (as opposed to just the name of the package to install from the web)
install.packages("<local-path-to-downloaded-zip-file>", repos=NULL)

Install an R package directly from a URL for the package source

I would like to install a package directly from a URL for the package source. I want to do this to make it easy for people to test a pre-release version of the package which should not be widely (or permanently) available. This is a similar question but it is different because it only describes how to install from local files not general URLs.
For the sake of this question I will use a link to the boot package source. Reading ?install.packages particularly the description of the pkgs argument suggests:
install.packages(
"http://cran.r-project.org/src/contrib/Archive/boot/boot_1.3-7.tar.gz",
repos = NULL, type = "source"
)
However this fails with:
Warning in install.packages :
installation of package
‘http://cran.r-project.org/src/contrib/Archive/boot/boot_1.3-7.tar.gz’
had non-zero exit status
Suggesting that the URL is being interpreted as the package name, not its location.
We can work around this with the following two step procedure:
download.file(
"http://cran.r-project.org/src/contrib/Archive/boot/boot_1.3-7.tar.gz",
"boot"
)
install.packages("boot", repos = NULL, type = "source")
But I would prefer to do this with a single call to install.packages only; and since install.packages is capable of downloading files anyway I feel this should be possible.
install.packages now works with http URLs (not https yet) as of 3.1.1. This works for me:
install.packages("http://www.lepem.ufc.br/jaa/colorout_1.1-0.tar.gz", repos=NULL)
Edit: As of R 3.2.0, https is builtin via libcurl. This should work now:
install.packages("https://github.com/hadley/devtools/archive/v1.7.0.tar.gz",
repos=NULL, method="libcurl")
Edit: As of R 3.2.2, https should work with default options assuming libcurl support was compiled in.
Edit 2016-04-20: There may be some issues downloading packages hosted on S3, but method='wget' seems to work for those for now.
See ?install_url in the devtools package.
Why not set up the directory in which you store the source package as a repository?
Here is an example (though you'd likely want to substitute type="source" for the type="win.binary" in the code at that link).
If the url is a github repository, try: install_github()
e.g.
library(devtools)
install_github("DeveloperName/PackageName")
# e.g. install_github("cran/seoR")

Did the subdirectory structure of package repositories change as of R 2.15.2?

Kind of embarrassing / a no-go, but since it hasn't been that long that I've moved from "pure user" to "beginner-developer", I've never actually read the CHANGELOG when a new R version came out - well until today (and I have the feeling I should make this a habbit) ;-)
Yet I'm not sure if the supposed change actually occurred since I couldn't find anything about it at a first glimpse at the CHANGELOG of R R 2.15.2:
Actual question
Is it possible that the (subdirectory) structure of package repositories changed from
./bin/windows/contrib/2.xx/
to
./src/contrib/2.xx/ or even ./src/contrib?
Or at least that the PACKAGES file now needs to live here: ./src/contrib/PACKAGES?
Background info
Up to version 2.15.1, the following path worked to install packages from my local package repository:
path.repos <- "L:/R/packages"
repos <- file.path("file://", path.repos)
Function contrib.url would take repos and expand it to the right subdirectory:
> contrib.url(repos)
[1] "file:///L:/R/packages/bin/windows/contrib/2.15"
But when I try to run install.packages(), I get the following error for R 2.15.2:
> install.packages("mypkg",
+ lib=file.path(R.home(), "library"),
+ repos=repos,
+ type="win.binary"
+ )
Error in read.dcf(file = tmpf) : cannot open the connection
In addition: Warning message:
In read.dcf(file = tmpf) :
cannot open compressed file 'L:/R/packages/src/contrib/PACKAGES', probable reason 'No such file or directory'
>
When I do the same with R 2.15.1, everything works smoothly.
Due dilligence
There are some references with respect to repositories in the CHANGELOG, but the only section I found that gives me some evidence that the supposed change occurred is this:
PACKAGE INSTALLATION
For a Windows or Mac OS X binary package install, install.packages() will check if a source package is available on the same repositories, and report if it is a later version or there is a source package but no binary package available.
Just had a look at the official documentation again and got the idea that maybe arg type is not passed along to contrib.url() correctly as it seems to me install.package() is looking at the place for type="source" packages?
This particular bug isn't the same as mine.
This issue relates to checks install.packages() now runs before installing. As Rappster said, it tries to find a source package to compare the binary version with:
For a Windows or Mac OS X binary package install, install.packages() will check if a source package is available on the same repositories, and report if it is a later version or there is a source package but no binary package available.
So a simple way of squashing this message is creating the R/src/contrib directory and running tools::write_PACKAGES() in that directory to create (an empty) PACKAGES file.
And of course, the reason you aren't getting this message in 2.15.1 is that it doesn't do the checking (see R NEWS quote above) that 2.15.2 performs.
I have submitted a bug report of my issues. No news yet. May post it to the R mailing list as well.

Resources