install cnv-seq.tar.gz in R - r

I'm trying to install this cnv-seq package on my R library to help copying number variation analysis. However, when I type in
install.packages("cnv-seq")
in R command, an error code pops out saying it is not available for 3.1.1 version. So I tried the old versions as well. All says not available. And I double check with the menu, Packages-> Install packages->. No cnv-seq
Ok. Then I tried to install it from a local source which is the "cnv-seq.tar.gz"
when i type in
install.packages("C:/cnv-seq.tar.gz", repos=NULL, type="source")
it still returns an error that says cannot extract package from this file.
Installation of package had non-zero exit status.
Anything went wrong or is there another I can install this package manually to my PC? After take a look at a similar question here couple years ago,
How do I install an R package from source?
I still could not fix this problem.

This is a case of RTFM ;)
You can do the whole process from within R. Below, we download the archive to the temporary directory, then extract it and finally install it.
download.file('http://tiger.dbs.nus.edu.sg/cnv-seq/cnv-seq.tar.gz',
f <- tempfile())
untar(f, exdir=tempdir())
install.packages(file.path(tempdir(), 'cnv-seq', 'cnv'), type='source', repos=NULL)

I believe you first must untar the file. I believe 7zip has this capability if you do not have access to a linux machine. The linux command would be:
tar -xvf /path/to/file/cnv-seq.tar.gz
After you do this you should be able to import the package into R.

Related

Installing R packages in macOS Mojave: Error in if (nzchar(SHLIB_LIBADD))

I have been trying to install R packages directly from the terminal but I am struggling much more than setting up the libraries I want in Windows. Sometimes it works if I install every single dependency for more complex packages by downloading them from CRAN and placing them in the R folder.
I appreciate this is not efficient but the recurrent error if I run R within the terminal while installing some of the packages is the following:
** libs
Error in if (nzchar(SHLIB_LIBADD)) SHLIB_LIBADD else character() :
argument is of length zero
* removing ‘/anaconda3/lib/R/library/<package name>’
[...]
In install.packages("<package name>") :
installation of package ‘fpc’ had non-zero exit status
I have been looking across many forums but the only solution I found so far is to install single dependencies manually by downloading them and dropping them in the master R folder. It is taking way longer than expected.
Any suggestion will be appreciated. Thanks
in my case (centos 7):
/home/xilab/miniconda3/lib/R/etc/Makeconf is a empty file!
find ~ -name Makeconf
/home/xilab/miniconda3/pkgs/r-base-3.6.1-hce969dd_0/lib/R/etc/Makeconf
/home/xilab/miniconda3/pkgs/r-base-3.6.1-h8900bf8_2/lib/R/etc/Makeconf
/home/xilab/miniconda3/envs/python2.7/lib/R/etc/Makeconf
/home/xilab/miniconda3/lib/R/etc/Makeconf
/home/xilab/miniconda3/pkgs/r-base-3.6.1-hce969dd_0/lib/R/etc/Makeconf is not empty,so:
mv /home/xilab/miniconda3/lib/R/etc/Makeconf /home/xilab/miniconda3/lib/R/etc/Makeconf.backup
cp /home/xilab/miniconda3/pkgs/r-base-3.6.1-hce969dd_0/lib/R/etc/Makeconf /home/xilab/miniconda3/lib/R/etc/Makeconf
problem solved!
I have seen this problem in conda version of R where /yours/anaconda/environment/lib/R/etc/ has a file Makeconf.mro.original together with an empty Makeconf file. This should not be intended.
During installation of some packages R checks what is within this Makeconf file, one such check is for SHLIB_LIBADD.
I just backed up the empty (or whatever) Makeconf file. Then copied Makeconf.mro.original to Makeconf.
This solved my case.
EDIT:
Recently I saw in centos-machine that Makeconf.mro.original file is not made after install.packages("name of library") failed. There is no easy solution for this.
In my case R installation was inside a conda environment. So, I created a new conda environment with R installation. The fresh installation has a Makeconf file in etc directory. So, I copied the Makeconf file from fresh R to my previously working R's etc directory.
It may be better to keep a backup copy of Makeconf from etc to a Makeconf.bak for future problems, in your working R etc directory.
I hope this helps for some cases.
I had this problem when trying to run install.packages("RPostgres") in a conda-installed version of R . The solution was to use conda as the package manager instead of R's install.packages function. That meant running these commands at a normal system command prompt (not in R):
conda search -c conda-forge RPostgres
# shows various versions of r-rpostgres
conda install -c conda-forge r-rpostgres

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.

How to re-install a modified R package

Technically I have 2 probs when I tried to install a package:
1. The package can be installed normally from github by devtools::install_github, however, when I download the zip file and try to manually install it from R or RStudio, I failed. The package seems can't be installed in this way. So could somebody explain that.
2. I tried to fix some bugs by modifying the .r source codes in R directory of the package unzipped folder. Then I think I need to re-compile/re-construct the package. Could some one give me a tutorial to do that.
IOS: Windows10, 64bit; R and Rtools are both the newest.
For prob1, here is the screen capture:
Thanks.
Close R and RStudio (if applicable) and uninstall the package manually by deleting its folder from your file system
For your 2nd problem after following #1 you can reinstall it by installing from source:
install.packages(path_to_file, repos = NULL, type="source")
Please confirm that these worked for you or let me know if not.

How to upload arules package in R

I am not able to upload arules package
Below is the following command I am using
library(arules)
I have downloaded the file from http://cran.r-project.org/web/packages/arules/index.html still it is not able to upload it.
Can anyone help me out
install.packages("arules")
pls. find below GUI - Screen for Rcmdr Package
Open RStudio.
Go to the “Packages” tab and click on “Install Packages”. The first time you’ll do this you’ll be prompted to choose a CRAN mirror. R will download all necessary files from the server you select here. Choose the location closest to you (probably “USA CA 1” or “USA CA 2”, which are housed at UC Berkeley and UCLA, respectively).
Install packages in Windows
Start typing “Rcmdr” until you see it appear in a list. Select the first option (or finish typing Rcmdr), ensure that “Install dependencies” is checked, and click “Install”.
Install Rcmdr in Windows
Wait while all the parts of the R Commander package are installed.
I had a similar problem. I solve it using
#install and load devtools to install directly from github
install("devtools")
library("devtools")
install_github("mhahsler/arules")
If you want to install "arules" package, you may not be able to install it just using the code below.
<< install.packages("arules") >>
follow the steps in order to solve problem:
go to the package's address and download it manually.you will find it in the link below:
https://cran.r-project.org/web/packages/arules/index.html
If you are using R-Studio just install that package you have got, by "tools" menu in your IDE (R-studio)
Tools->Install packages->...
brows the file in your computer and install it.
go to the command line and using library(arules) function test the package. If there is still an error it could belong to incompatibility of the package with the version of R (Not R-Studio or any other IDE that you are using), just upgrade R and try installation period again.
I had a related problem where I could not install arules after being able to successfully install many libraries. I finally learned that I needed to update to 3.4 for arules. In order to do that, I followed duckmayr's answer HERE. Then, I was able to install arules with no issues, and it worked.

How do I install an R package from the source tarball on windows?

The forecast package for R has been updated to version 2.12, but there are currently only windows binarys for 2.11 available on CRAN.
How do I install an R package from the source on Windows?
I know this is an old question but it came up first in my Google search for this same question, even though I knew the answer I just wanted something to copy and paste. Which makes it worth improving the answer for future reference. So here is what works for me:
Install rtools, then:
install.packages(path_to_file, repos = NULL, type="source")
Two answers that may help you avoid the hassle of installing Rtools.
Use http://win-builder.r-project.org/ to build a binary version, download it, and install (using install.packages(...,repos=NULL))
If the package has no binary component (i.e. no src directory with C, C++, or Fortran code that needs to be compiled during installation (not true for forecast, but possibly useful some other time) then simply specifying type="source" within the install.packages call (whether from a repository or a local copy of the source tarball (.tar.gz file)) will install the source package, even on Windows.
Start by reviewing the section on Windows packages in the R Installation and Administration manual, then carefully follow the instructions from The Windows toolset appendix.
I know it's usually bad form to mainly provide links in an answer, but these are links to the canonical references on this topic. I simply link to them rather than summarize their contents, since they should be accurate for the most current R release.
I'm not sure if this is the best way, but I found the following method to work (based in part on the answers above):
1) Download the package .tar
2) Move the package to the directory with your user R libraries (e.g., in my case it was "C:/Users/yourUserName/Documents/R/win-library/3.3")
3) Within Rstudio (or elsewhere, probably), run the command... install.packages("packageName.tar", repos=NULL, type="source")
That worked for me at least. Hope it's helpful!
Download the package *.tar.gz.
make sure you have Rtools installed.
Make sure the R and Rtools paths are added in the environment varialble.
Open a command prompt. Type R CMD INSTALL packagename.tar.gz.
it will work i hope.
To install a package from a .tar.gz file, follow these steps:
Launch R to have the R command prompt
Type: install.packages(<path_to_tar.gz_file>, repos = NULL)
or launch directly:
R CMD INSTALL <path_to_.tar.gz_file>
You need to have R installed but you don't need RTools

Resources