I try to build fork of R package from github (this fork has a fresh bugfix). I am able to build AND install the package from github:
require(devtools)
install_github("patcpsc/rredis", build_vignettes = FALSE)
However, this doesn't produce installable package - or does it? I need to install this package on 15 machines so I prefer to build the package once and then copy and install it on the other machines.
I tried to look for funciton like build_github, unfortunatelly there is none. How do I do it?
github has help documentation on how to fork a repository. It sounds like you've done the first part. Now you just need to clone the repository. That means taking a copy for your local machine so you can work on it. The buttons you want are on the right. Clone in desktop is for when you use the Github desktop software. If you are running git from a command line, type
git clone git#github.com:whatever-the-link-is-in-the-SSH-clone-url-textbox
Once you have a local copy of the repository, in R you do
library(devtools)
build("path/to/package/root")
I thought you wanted to actually work on the package. If you just want to download the source, there's a "Download ZIP" button right underneath the clone options. Download, unzip, then build in R as above.
It's old question and a lot changes since 2014. Now the workhorse is remotes package.
If you want installable package there is one created in your temp directory.
I usually don't want install so I create temporary library:
dir.create(tmp_lib <- "tmp_lib")
.libPaths(c(tmp_lib,.libPaths()))
.libPaths()
But you can skip that if not needed, now standard:
require(devtools)
install_github("patcpsc/rredis", build_vignettes = FALSE)
Now navigate to your temp location given by tempdir() (in Windows shortcut is: shell.exec(tempdir())).
You should see folder [fileXXXXXXXX] which should contain rredis_1.6.9.tar.gz file. This is what you need.
unlink(tmp_lib, recursive=TRUE) cleanup your temp directory.
Related
I need to have the tar.gz build version of a package from git.
The git link would look like
devtools::install_github('repo/package#x.1.0')
Let's assume it is
devtools::install_github("tidyverse/lubridate") but instead of installing I need the actual file so I can install it in in an offline container at some point.
The package I need is not on CRAN, on git only, and I need a specific version of the release, not the latest.
I tried to run a different download.file arguments, no success.
This, question, is, asked, over, and, over, and, over,
on the R-sig-finance mailing list, but I do not think it has been asked on stackoverflow.
It goes like this:
Where can I obtain the latest version of package XYZ that is hosted on R-forge? I tried to install it with install.packages, but this is what happened:
> install.packages("XYZ",repos="http://r-forge.r-project.org")
Warning message: package ‘XYZ’ is not available (for R version 2.15.0)
Looking on the R-forge website for XYZ, I see that the package failed to build.
Therefore, there is no link to download the source. Is there any other way
to get the source code? Once I get the source code, how can I turn that into a
package that I can load with library("XYZ")?
R-Forge may fail to build a package for a few different reasons. It could be that
the documentation has not been updated to reflect recent changes in the code. Or,
it could be that some of the dependencies were not available at build time.
You can checkout the source code using svn. First, search for the project on the
R-Forge website and go to the project home page -- for example http://r-forge.r-project.org/projects/returnanalytics/
Click the SCM link to get to a page like this http://r-forge.r-project.org/scm/?group_id=579
This page will tell you the command to use to checkout the project. In this case you get
This project's SVN repository can be checked out through anonymous access with the following command(s).
svn checkout svn://svn.r-forge.r-project.org/svnroot/returnanalytics/
If you are on Windows, you probably want to download and install TortoiseSVN
Once you have installed TortoiseSVN, you can right click in a Windows Explorer window and select
"SVN checkout". In the "URL of repository:" field, enter everything except the
"svn checkout " part of the command that you found on R-Forge. In this case, you'd
enter "svn://svn.r-forge.r-project.org/svnroot/returnanalytics/".
When you click OK, the project will be downloaded into the current directory.
If you are on a UNIX-alike system (or if you installed the command line client tools
when you installed TortoiseSVN for Windows, which is not the default), you can
type the command that R-forge gave you in your terminal (System terminal, not the R terminal)
svn checkout svn://svn.r-forge.r-project.org/svnroot/returnanalytics/
That will create a new directory under the current working directory that
contains all of the files in the package. In the top level of that directory
will be a subdirectory called "pkg". This particular project (returnanalytics)
contains more than one package.
ls returnanalytics/pkg
#FactorAnalytics MPO PApages PerformanceAnalytics PortfolioAnalytics
But some R-forge projects only have a single package. e.g.
svn checkout svn://svn.r-forge.r-project.org/svnroot/random/
#Checked out revision 14.
ls random/pkg
#DESCRIPTION inst man NAMESPACE R
Now that you have a local copy all of the code, if you would like to be able to
install the package, you have to build it first.
A WORD OF CAUTION: Since R-Forge failed to build the package, there is a good chance
that there are problems with the package. Therefore, if you just build it, you may find
that some things do not work as expected. In particular, it is likely that there
is missing or incomplete documentation.
If you are on a UNIX-alike system, the package can be built and installed relatively easily. For a multi-package project like returnanalytics, if you want to install, e.g. the
PortfolioAnalytics package, you can do it like this
R --vanilla CMD INSTALL --build returnanalytics/pkg/PortfolioAnalytics
"PortfolioAnalytics" is the name of the directory that contains the package that
you want to build/install. For a single-package project, you can build and install like
this
R --vanilla CMD INSTALL --build random/pkg
If you would like to build/install a package on Windows, see this question and follow the two links that #JoshuaUlrich provided
More information can be found in R Installation and Administration, the R-Forge User Manual, and the SVN manual.
If (and only if) you have the appropriate toolchain for your OS, then this may succeed:
# First download source file to your working directory
# As an example use browser to download pkg:partykit from:
# http://download.r-forge.r-project.org/src/contrib/partykit_1.1-2.tar.gz
# Move to working directory
# Or in the case of returnanalytics (which is a bundle of packages):
# http://r-forge.r-project.org/R/?group_id=579 and download the tar.gz (source)
# Then in R:
install.packages( "partykit_1.1-2.tar.gz", repo=NULL, type="source")
# for the first of the ReturnAnalytics packages:
install.packages( "Dowd_0.11.tar.gz", repo=NULL, type="source")
These direction should be "cross-platform". I'm not sure the directions in the accepted answer are applicable to Macs (OSX). (I later confirmed that they do "work" on a Mac but found the process more involved that what I suggested above. They do result in a directory that do contain the packages in a form that should succeed with R --vanilla CMD INSTALL --build pathToEachPackageSeparately)
It is also possible that the current version of the package you are trying to install requires a newer version of R, for example, you may see error like:
"ERROR: this R is version 2.15.0, package 'PerformanceAnalytics' requires R >= 3.0.0"
then you can try to update your R
or, if you are facing the same situation with me, which is trying to use pqR (currently using R version 2.15), you can find the out-of-date achieved package here:
http://cran.at.r-project.org/src/contrib/Archive/PerformanceAnalytics/
You can get here from R-Forge packages page -> "Stable Release: Get PerformanceAnalytics 1.4.3541 from CRAN" -> Old sources: PerformanceAnalytics archive
for example, you will find package PerformanceAnalytics version 1.1.0 just requires R >= 2.14
Good luck
Alternatively, you can install the particular package from GitHub, if it has a repo at GitHub.
I ran install.packages('ggfortify'), and got
Warning message: “package ‘ggfortify’ is not available (for R version
3.3.2)”
ggfortify was the GitHub repo for the same package.
The devtools library allows you to install a package from GitHub directly with install_github('username/repo').
library(devtools)
install_github('sinhrks/ggfortify')
I want to set up a local CRAN repository . I want to put just one package in this repository ( let's call it MyPackage ). The reason I'm doing this is that I want to share this package with people at my company. By the way - we all use Ubuntu Linux.
I have already done this:
I have a web server ( BOA web server ) and made a web folder called R. Made folder src and contrib.
In the contrib folder I put my package MyPackage ( tar.gz) plus the PACKAGES file.
However, when I do this:
install.packages("MyPackage", repos = "127.0.0.1/R" )
it does not work ;
Warning: unable to access index for repository [ ]
Warning message:
In getDependencies(pkgs, dependencies, available, lib) :
package ‘MyPackage’ is not available (for R version 2.13.1)
Can you guys guide me a bit and tell me what is the correct folder structure ?
Thanks.
See "Section 6.6 Setting up a package repository" of the R Admin manual.
Edit some three+ years later: We now have the drat package which automates creating a repository, and can use GitHub in a clever way to host it for you.
You might just need to specify the URL properly; http://127.0.0.1/R.
Also, make sure you can access that URL in your browser.
The miniCRAN works good for me. There are few advantages to using miniCRAN to create the repository:
Security: Many R users are accustomed to downloading and installing new R packages at will, from CRAN or one of its mirror sites.
Easier offline installation: To install package to an offline server requires that you also download all package dependencies, Using miniCRAN makes it easier to get all dependencies in the correct format.
Improved version management: In a multiuser environment, there are good reasons to avoid unrestricted installation of multiple package versions on the server.
Use other R Package Indexes: You may wish to make packages available from public repositories other than CRAN, e.g. BioConductor, r-forge, OmegaHat, etc.
Prepare own R repo: You may wish to add custom in-house packages to your repository.
See intro:
Using miniCRAN to create a local CRAN repository
Create a local package repository using miniCRAN
I think the problem is revealed in this statement:
"In the contrib folder I put ... the PACKAGES file."
The PACKAGES file is an index for the repository. You need to create that file after your package files are placed in the repository directory. Don't copy and paste the PACKAGES file from another repository.
If I were you, here's what I would do. First, add the following code to your .Rprofile for a local repository:
utils::setRepositories(ind = 0, addURLs = c(WORK = "127.0.0.1/R"))
Restart R after changing your .Rprofile.
ind = 0 will indicate that you only want the local repository. Additional repositories can be included in the addURLs = option and are comma separated within the character vector.
Then, create the repository index:
tools::write_PACKAGES("127.0.0.1/R/src/contrib", verbose = TRUE)
After you do that, you should be able to generate a data frame that has a list of all the packages. For example, my_packages <- available.packages().
If you see packages in your repository data frame, then install using the following code:
install.packages("MyPackage")
For more information, please see here.
This, question, is, asked, over, and, over, and, over,
on the R-sig-finance mailing list, but I do not think it has been asked on stackoverflow.
It goes like this:
Where can I obtain the latest version of package XYZ that is hosted on R-forge? I tried to install it with install.packages, but this is what happened:
> install.packages("XYZ",repos="http://r-forge.r-project.org")
Warning message: package ‘XYZ’ is not available (for R version 2.15.0)
Looking on the R-forge website for XYZ, I see that the package failed to build.
Therefore, there is no link to download the source. Is there any other way
to get the source code? Once I get the source code, how can I turn that into a
package that I can load with library("XYZ")?
R-Forge may fail to build a package for a few different reasons. It could be that
the documentation has not been updated to reflect recent changes in the code. Or,
it could be that some of the dependencies were not available at build time.
You can checkout the source code using svn. First, search for the project on the
R-Forge website and go to the project home page -- for example http://r-forge.r-project.org/projects/returnanalytics/
Click the SCM link to get to a page like this http://r-forge.r-project.org/scm/?group_id=579
This page will tell you the command to use to checkout the project. In this case you get
This project's SVN repository can be checked out through anonymous access with the following command(s).
svn checkout svn://svn.r-forge.r-project.org/svnroot/returnanalytics/
If you are on Windows, you probably want to download and install TortoiseSVN
Once you have installed TortoiseSVN, you can right click in a Windows Explorer window and select
"SVN checkout". In the "URL of repository:" field, enter everything except the
"svn checkout " part of the command that you found on R-Forge. In this case, you'd
enter "svn://svn.r-forge.r-project.org/svnroot/returnanalytics/".
When you click OK, the project will be downloaded into the current directory.
If you are on a UNIX-alike system (or if you installed the command line client tools
when you installed TortoiseSVN for Windows, which is not the default), you can
type the command that R-forge gave you in your terminal (System terminal, not the R terminal)
svn checkout svn://svn.r-forge.r-project.org/svnroot/returnanalytics/
That will create a new directory under the current working directory that
contains all of the files in the package. In the top level of that directory
will be a subdirectory called "pkg". This particular project (returnanalytics)
contains more than one package.
ls returnanalytics/pkg
#FactorAnalytics MPO PApages PerformanceAnalytics PortfolioAnalytics
But some R-forge projects only have a single package. e.g.
svn checkout svn://svn.r-forge.r-project.org/svnroot/random/
#Checked out revision 14.
ls random/pkg
#DESCRIPTION inst man NAMESPACE R
Now that you have a local copy all of the code, if you would like to be able to
install the package, you have to build it first.
A WORD OF CAUTION: Since R-Forge failed to build the package, there is a good chance
that there are problems with the package. Therefore, if you just build it, you may find
that some things do not work as expected. In particular, it is likely that there
is missing or incomplete documentation.
If you are on a UNIX-alike system, the package can be built and installed relatively easily. For a multi-package project like returnanalytics, if you want to install, e.g. the
PortfolioAnalytics package, you can do it like this
R --vanilla CMD INSTALL --build returnanalytics/pkg/PortfolioAnalytics
"PortfolioAnalytics" is the name of the directory that contains the package that
you want to build/install. For a single-package project, you can build and install like
this
R --vanilla CMD INSTALL --build random/pkg
If you would like to build/install a package on Windows, see this question and follow the two links that #JoshuaUlrich provided
More information can be found in R Installation and Administration, the R-Forge User Manual, and the SVN manual.
If (and only if) you have the appropriate toolchain for your OS, then this may succeed:
# First download source file to your working directory
# As an example use browser to download pkg:partykit from:
# http://download.r-forge.r-project.org/src/contrib/partykit_1.1-2.tar.gz
# Move to working directory
# Or in the case of returnanalytics (which is a bundle of packages):
# http://r-forge.r-project.org/R/?group_id=579 and download the tar.gz (source)
# Then in R:
install.packages( "partykit_1.1-2.tar.gz", repo=NULL, type="source")
# for the first of the ReturnAnalytics packages:
install.packages( "Dowd_0.11.tar.gz", repo=NULL, type="source")
These direction should be "cross-platform". I'm not sure the directions in the accepted answer are applicable to Macs (OSX). (I later confirmed that they do "work" on a Mac but found the process more involved that what I suggested above. They do result in a directory that do contain the packages in a form that should succeed with R --vanilla CMD INSTALL --build pathToEachPackageSeparately)
It is also possible that the current version of the package you are trying to install requires a newer version of R, for example, you may see error like:
"ERROR: this R is version 2.15.0, package 'PerformanceAnalytics' requires R >= 3.0.0"
then you can try to update your R
or, if you are facing the same situation with me, which is trying to use pqR (currently using R version 2.15), you can find the out-of-date achieved package here:
http://cran.at.r-project.org/src/contrib/Archive/PerformanceAnalytics/
You can get here from R-Forge packages page -> "Stable Release: Get PerformanceAnalytics 1.4.3541 from CRAN" -> Old sources: PerformanceAnalytics archive
for example, you will find package PerformanceAnalytics version 1.1.0 just requires R >= 2.14
Good luck
Alternatively, you can install the particular package from GitHub, if it has a repo at GitHub.
I ran install.packages('ggfortify'), and got
Warning message: “package ‘ggfortify’ is not available (for R version
3.3.2)”
ggfortify was the GitHub repo for the same package.
The devtools library allows you to install a package from GitHub directly with install_github('username/repo').
library(devtools)
install_github('sinhrks/ggfortify')
I am trying to install the r package "segue" from the source. Unfortunately, there's no tarball provided at this time, and I don't know how to compile and install a package from the binary files. I'm on a mac, if that helps.
Thanks!
As the author of Segue, I threw you a bone and rolled the tar ball for you :)
What you see on the Google Code page is not the binary files, they are the source files. Now me doing it for you is not that helpful for helping you understand packages. So if you wanted to build this yourself, here's how you would do it:
clone the source tree so you have a local copy on your machine. Make sure you have Mercurial installed and then type hg clone https://segue.googlecode.com/hg/ segue to clone the code to your machine.
build the package, test it, and install with the following three commands:
R CMD build segue/
R CMD check segue_0.02.tar.gz
R CMD INSTALL segue_0.02.tar.gz
I've never actually used a Mac so I think these commands are right. I know they work on Linux. So let me know if I need to alter these instructions for Mac. You're helping me write documentation!