I am trying to install the R package MixeR 2003 by Batagelj and Bren . This is not in CRAN, but is accessible on this website as a downloadable zip file containing an R file (MixeR.R), a dataset (Glac.dat) and 3 pdf's.
I downloaded the zip file, and placed it in my R directory. After that, I attempted to install it from within RStudio using the drop-down menus Tools > Install Packages > Package Archive File (.zip; .tar.gz) > MixeR.zip, getting the following error message:
install.packages("~/R/MixeR.zip", repos = NULL, type = "win.binary")
Installing package into ‘C:/Users/Documents/R/win-library/3.3’
(as ‘lib’ is unspecified)
Warning in install.packages :
cannot open compressed file 'MixeR/DESCRIPTION', probable reason 'No such file or directory'
Error in install.packages : cannot open the connection
What am I doing wrong, and how can I install this package?
It may very well be that it is actually not a package, but rather a 'library', in which case I would appreciate guidance as to how to make the functions and datasets in it accessible to the R session.
If you download and extract you'll see that that it's some pdfs, a .dat file, and a single R script that contains a bunch of functions.
Likely you just want to source the script so you want to extract the zip archive and then use source on MixeR.R
source("path/to/MixeRArchive/MixeR.R")
Alternatively they do host that file on their website directly so you could just read it from the internet directly
source("http://vlado.fmf.uni-lj.si/pub/MixeR/MixeR.R")
Either way will read the functions directly into your global environment since it isn't an actual package with its own namespace.
Related
I already referred this post,post,
I am trying to install an R package called Aphrodite.
So, I downloaded the zip folder of R package from github and tried the below command
install.packages("C:/Users/test12/Downloads/Aphrodite.zip",repos=NULL,dependencies=TRUE,type="source")
The above command results in below message and moves the cursor to next line without any error message. Please note that all my packages goes into the below folder only.
Installing package into ‘C:/Users/test12/Documents/R/win-library/3.6’
(as ‘lib’ is unspecified)
However, when I try to use the below command, I get an error as shown below
library(Aphrodite)
Error in library(Aphrodite) :
‘Aphrodite’ is not a valid installed package
I also tried the below option but it doesn't display some of the folders which are available in the master directory. The details of it can be referred in this post
install.packages("devtools")
library(devtools)
install_github("ohdsi/Aphrodite") #APHRODITE is the package name
library(Aphrodite)
How can I load the package when it is installed from a custom directory? Why the package is not being recognized even though it is in the usual libpath folder?
I am trying to load a self-written package in order to use the functions I created there without having to copy and paste them into each new project. The program is having difficulties to recognize the package though. These are the lines I am inputting and the messages issued by the system.
> .libPaths(c(.libPaths(), "path-to-package"))
> install.packages("somepath/myPackage.zip", repos = NULL, lib = "path-to-package")
> library("myPackage", lib.loc = "path-to-package")
Error in library("myPackage", lib.loc = "path-to-package") :
‘myPackage’ ist keine gültiges installiertes Paket
After issuing "install.packages", new directories and files are displayed in Microsoft Explorer. While other files vanish at the end, the directory named "myPackage" remains.
Would it be easier to try and get R do my bidding and make it recognize myPackage as a package not only when installnig, but also when loading it? Or is it easier to copy and paste the functions from the package when I need them?
I do own the book "R Packages" by Hadley Wickham in its first edition from 2015. Are there any passages I might want to reread to get going?
I am trying to install packages on a remote windows machine with no internet connection using source packages. I am trying to follow the instructions given in an answer to the previous question
Offline install of R package and dependencies
I have a folder with .tar.gz files for the package and it's dependencies. I run the commands
library(tools)
write_PACKAGES()
which generates the PACKAGES and PACKAGES.gz in the same folder. However, my PACKAGES file is empty (with size 0 KB).
When I try to install the package using
install.packages("<PACKAGE_NAME>", contriburl = "file:///")
(I am in the same directory as all the source files), I am getting the following error
cannot open compressed file '//PACKAGES', probable reason 'No such file or directory'
I am not sure if there is something wrong with the way I specify the path or is it because my PACKAGES file is empty that I am getting this error.
Any help here would be great!
Additional info - The remote machine is a Windows machine and I have also tried deleting the PACKAGES.gz file before installing (as recommended in the link above), but did not succeed.
Thanks!
SN248
I was able to install the package that I wanted (package name = dplyr), using the hints in the comments above. I needed to change two things
I downloaded windows binaries instead of source files, using type = "win.binary" parameter in the download.packages command.
The path in contriburl = "file:///" needed to be changed to contriburl = "file:///<ABSOLUTE_PATH_TO_FOLDER_WITH_WIN_BINARIES>"
With these changes, the package installation went successfully.
Hope it helps others.
SN248
I need to download packages and install from local directory. But I'm having trouble installing ggplot2. I get no warning, but it seems the library is not installed. Output is below, any suggestions? Operating system is Windows. After running, the directory C:...\R\win-library\3.1 contains subdirectory ggplot2-master.
> install.packages("C:/.../packages/ggplot2-master.zip", repos = NULL, type="source")
Installing package into ‘C:/.../R/win-library/3.1’
(as ‘lib’ is unspecified)
> library(ggplot2)
Error in library(ggplot2) : there is no package called ‘ggplot2’
The correct action was to download the binaries instead of the source.
Note, the following command prompts for the file path:
install.packages(file.choose(), repos=NULL)
The computer is behind a firewall, so the install.package command does not work. I should have downloaded the binary install, but downloaded the source by mistake. So, the corrective action is to download the binary files. I want to point out that in my notes on R, it clearly states to download the binary file. Part of the joys of getting older, not remembering why I came into this room.... Also, rambling...
I am trying to use Google Trends data and have come across a few packages that are not on CRAN (GTrends, RGoogleTrends).
I like what I have seen from the RGoogleTrends package at this blog, and wanted to give it a try. The RGoogleTrends package is located here: http://www.omegahat.org/RGoogleTrends/
First of all, I am using a Windows OS and there is an uption in my R console:
>Packages>Install package(s) from local zip drives ...
This results in the following:
> utils:::menuInstallLocal()
Error in read.dcf(file.path(pkgname, "DESCRIPTION"), c("Package", "Type")) :
cannot open the connection
In addition: Warning messages:
1: In unzip(zipname, exdir = dest) : error 1 in extracting from zip file
2: In read.dcf(file.path(pkgname, "DESCRIPTION"), c("Package", "Type")) :
cannot open compressed file 'RGoogleTrends_0.2-1.tar.gz/DESCRIPTION', probable reason 'No such file or directory'
I'm guessing this has to do with the fact that the file is as a .gz and not a .zip file.
So, I unzipped the .gz file outside of R and then zipped it into a .zip file (there's got to be a better way). Now I can install the .zip file, but when I try and load it with library, the following error occurs:
> library(RGoogleTrends)
Error in library(RGoogleTrends) :
‘RGoogleTrends’ is not a valid installed package
What am I doing wrong here?
You will need R version 3 for this, which you can get here for example:
http://cran.cnr.berkeley.edu/bin/windows/base/R-3.0.1-win.exe
Then open R and type:
install.packages("devtools")
require(devtools)
install_url("http://www.omegahat.org/RGoogleTrends/RGoogleTrends_0.2-1.tar.gz")
require(RGoogleTrends)
ls("package:RGoogleTrends")
You may get few warnings in the process. Ignore them. you should then be able to use the package.
I think a package builds differently for linux than to windows so a .gz version can't be converted to .zip
This link indicates you should be able to use just the unzipped version...
http://decisionstats.com/2013/04/26/using-a-linux-only-package-in-windows-rstats/
The comment in it suggests devtools or Rtools, both of which will allow direct installation from the gz file
To unzip and use directly
Extract from tar.gz to .tar
Extract from .tar
Set the working directory to the R subfolder e.g. Setwd( "C:\\Users\\x\\Documents\\RGoogleTrends_0.2-1.tar\\RGoogleTrends_0.2-1\\RGoogleTrends\\R")
Load all functions for (i in list.files()){source(i)}
To use devtools
Install devtools
library("devtools")
Setwd to folder containing .tar.gz file
install("RGoogleTrends_0.2-1.tar.gz")
To use Rtools
Download correct version from http://cran.r-project.org/bin/windows/Rtools/
Install from the .exe
Check whether you need to anything in http://cran.r-project.org/bin/windows/Rtools/Rtools.txt
Run R from your command line (cmd into search in start) - see
Setwd to folder containing .tar.gz file
R CMD INSTALL *.tar.gz
My preferred approach is devtools
I was having all sorts of issues with errors like:
not supported in current version
cannot find DEPENDENCIES
cannot unzip
If you are running windows and installed for all users and are running as a normal user (which you should be for all sorts of reasons) installing packages is interesting.
What I ended up doing was
close R
open R as admin
load base package
I had already downloaded the packages so I could install offline and they were in f:\software\rcontrib
then run:
files=list.files(path="f:/software/rcontrib",pattern="*.zip",include.dirs=TRUE)
for (i in seq(along=files)){install.packages(files[i],repos=NULL)}
This will bulk load packages from the local directory / common file share / non-internet location.
Then you can exit R. Running as any user on the machine you should be able to use the packages.
This will hopefully save people the couple of hours I wasted trying to bulk load and overcome errors in R which were actually windows security.