Installing custom R package in the WRDS cloud - r

I tried to install custom R package 'sf' in the WRDS cloud via interactive R session, but failed. The instruction from WRDS is:
https://wrds-www.wharton.upenn.edu/pages/support/programming-wrds/programming-r/installing-r-packages/
I followed the instructions and the package 'sf_0.9-6.tar.gz' is already in the '~/lib/R' directory:
When i tried to install the package in the interactive R session, i typed in the code :
install.packages("~/sf_0.9-6.tar.gz", lib = "~/lib/R")
I got the following error:
I don't understand why it is an invalid package, even though i've downloaded the package directly from CRAN. Besides, the package should work on the R 3.6.2.
Could anyone help? I would highly appreciated it!

I faced a similar issue with installation of another user-written package (from CRAN) on R 4.0.5 but, I guess, the root cause of the issue is the same which is that install.packages can not find the package TAR file in the directory /home/<institutionName>/<userName> (note: this is what the ~ stands for).
Could you try replacing your code:
install.packages("~/sf_0.9-6.tar.gz", lib = "~/lib/R")
with
install.packages("~/lib/R/sf_0.9-6.tar.gz", lib = "~/lib/R")
Expanding the path of the package to the newly created R sub-folder within the lib folder worked for me.

Related

Cannot install packages in Rstudio

I just installed R studio and I was trying to install rmarkdown. However, I got the error as below. I unchecked the box ''Tools -> Global Options -> Packages -> Use secure download method for HTTP'' as someone suggested. No help. I tried other packages, I got the same error.
You should remove the package and reinstall it using dependencies = TRUE:
remove.packages("rmarkdown")
install.packages("rmarkdown", dependencies = TRUE)
library(rmarkdown)
Output:
Warning message:
package ‘rmarkdown’ was built under R version 4.1.2
I had the same issue and it was due to the newest version of the toolboxes include the names is under new package names. Go to the URL https://cran.rstudio.com/src/contrib/PACKAGES and search for "rmarkdown". Find the package name and try to install that instead. It's like a .zip file that includes several packages to your library. Try install.packages("accucor"). It worked for me at least, and then try to install the rmarkdown package.

r package installed properly but "there is no package called ‘DiabetesTxPath-master" error

I'm trying to install a package called "DiabetesTxPath-master" from local files.(The file can be downloaded in https://github.com/rohit43/DiabetesTxPath)
I used the code below installing it.
'filename<-"DiabetesTxPath-master.zip"'
install.packages(filename,type="binary",repos=NULL)
but when I try to load the packaged by the code below,
library(DiabetesTxPath)
error comes up.
there is no package called ‘DiabetesTxPath-master'
There is no problem in location.
.libPaths()
[1] "C:/Program Files/R/R-3.4.2/library"'
and this is where I want my package to be installed.
(and I see my packaged installed in the folder with my eyes!)
2.I've also tried to run as an administrator. it didn't work either.
So what could be the probelm, and how could I fix this?
Any comment would be appreciated so much.
I've been trying it so hard for a week.
Try using
library(devtools)
install_github("rohit43/DiabetesTxPath")
the problem arises because the dependencies for this package
ERROR: dependencies 'FeatureExtraction', 'CohortMethod',
'OhdsiSharing' are not available for package 'DiabetesTxPath'
are not available for this package in R 3.5 and above .
Now you need to install older version of R where these dependencies were supported and try using the above method.

R: Error in install.packages : cannot open the connection

I was trying to install the package RINDSEL but I am unable to install it and I keep getting the following error:
Error in install.packages : cannot open the connection
I downloaded the package from:
rindsel_1.0_2.zip | Integrated Breeding Platform
and loaded it from the directory. Other packages from the directory can be installed but just not this one.
Is the package corrupt or could there be any other error?
I would really be grateful for any help. Thanks in advance
Rename the zip file RinSel Software into Rindsel. That's the name specified in the discription file.
Then, you can install the package in R with the command
install.packages("C:/path/to/Rindsel.zip",repos=NULL,type="win.binary")
That works fine... at first (!!!).
Problem with the Rindsel package is. It is quite old. It was build with R 2.13.1. Therefore, if you want to load the library which would be the next step to use the package in R you will get the error:
Problems building package (Error: "package has been build before R-3.0.0")
My suggestion: Contact the authors of the package and ask them if they can either provide the source file that you can build the package by yourself or if they can bundle the Rindsel package with a newer R version.
(Or you could try to hunt down an old R version and see if you can get the thing running with an old R... However, I would not seriously suggest to do that. It would probably result in conflicting dependencies with the other required packages...)
EDIT 15-02-2018: OP asked if one can build an R package with sources that are presumeably the Rindsel source files.
Yes, basically, you could do that. You would have to make a your own description and namespace file and put the source file in the R folder than invoke the command in R to build it....
But it's not neccessary with the script files provided by the link the OP posted.
OP, just run the scripts in R! It's quite easy.
Download the zip-file and extract it on your machine.
Go to that directory. The R command would be
setwd('path/to/your/directory')
Than run the R script, e.g, the KNIndex.r. It's simple:
source('KNIndex.r')
Then the script will run and produce some output / prompts.
For future readers,
I was able to fix the error by running RStudio with administrative privileges to get the command to work.
If that does not fix it, you might wish to try
Installing "r tools" if that is not installed already. That can be downloaded from
https://cran.r-project.org/bin/windows/Rtools/
Download a relevant package that you are trying to install (e.g., tidyverse_1.3.0.zip) from https://cran.rstudio.com/
and install that from local path
It can also be installed directly from the web using install.packages("https://cran.rstudio.com/bin/windows/contrib/4.0/tidyverse_1.3.0.zip")
I had the same problem. R was not able to extract and compile the package files to the default installation directory for some system-specific reasons (not R related).
I was able to fix this by specifying the installation directory of the package lib using:
install.packages("your package", lib = 'path/to your/required/installation/directory')
You can then load the package by specifying the lib.loc option while loading it:
library('your package', lib.loc='path/to your/required/installation/directory')
A better solution:
Create a new environment variable (if you are using windows) R_LIBS_USER with the following directory path/to your/required/installation/directory.
This will change the default installation directory of the packages and make it easier to load and install them without specifying the location everytime.

Trying to install library 'quantmod' in R

I'm trying to download library 'quantmod' in R:
install.packages("quantmod")
console:
The downloaded source packages are in
‘/tmp/RtmpwSKGIl/downloaded_packages’
then:
library("quantmod", lib.loc="/tmp/RtmpwSKGIl/downloaded_packages")
console:
Error in library("quantmod", lib.loc = "/tmp/RtmpwSKGIl/downloaded_packages") :
there is no package called ‘quantmod’
What is the problem?
I get no problem when I try to load this package.Have you tried to provide R the full name path to your package file directory ?C:/Users/...Is your R version up to date ? Try to check if you have the latest, I tried and it worked with :
R 3.3.3
If you are a Windows or MAC user you might want to force the download of the package from source to binary, this can be done by setting the right options in the install.packages command:
options(install.packages.check.source = "no")
https://stat.ethz.ch/R-manual/R-devel/library/utils/html/install.packages.html
I guess I am a year late, but just got out of this situation by installing the Package from R (instead of RStudio) by changing the CRAN.
You can then run library(quantmod) in Rstudio. Hope this works(worked?) for you too.
I am ready to go now!

Install package "locClass" in R

I want to install a package named "locClass" in R but always failed and kept getting the following warning:
install.packages("locClass", repos="http://download.r-forge.r-project.org/")
Package which is only available in source form, and may need compilation of C/C++/Fortran: ‘locClass’
These will not be installed
The install command is referred to: https://r-forge.r-project.org/R/?group_id=1187
Also, I downloaded the package source from the above website. But R returned the following:
library(locClass)
Error in library(locClass) : ‘locClass’ is not a valid installed package
My R version is 3.3.3. I tried the 3.4.0 but failed the same way.
This is not exactly a solution but an alternative to utilize functionality of package locClass. Download the package file of locClass from here and source(functions.R) present here. This way you can use all functions available in package.
Note : function.R means FLXMCL.R, FLXMCLconstant.R etc.
I'm still looking for a better solution but this is a temporary alternative.

Resources