Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install a particular tagged commit of an R package

Tags:

r

devtools

I have a personal R package with helper functions that I use in various projects. However, I would like to get a project working with a particular version of the project and then keep adding code. I understand I could do this with branches, but I'd prefer to do it with commit tags.

Looking at the documentation for devtools::install_git it seems that if I tag a commit then I should be able to install that particular commit, but that is not working for me.

This is a picture showing that I have a commit tagged "v0.0.1" enter image description here

But attempting to install it gives me this:

devtools::install_git(url = 'http://<username>@<company stash url>/scm/preamp.git', branch = 'v0.0.1')

# > Downloading git repo http://<username>@<company stash url>/scm/preamp.git
# > Error in .local(object, ...) : 'v0.0.1' did not match any branch

My R session information:

> sessionInfo()
R version 3.2.3 (2015-12-10)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.11.1 (El Capitan)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] parallel  splines   stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] tidyr_0.5.1                 lazyeval_0.2.0              assertthat_0.1             
 [4] beepr_1.2                   preamp_0.1                  stringr_1.0.0              
 [7] readr_0.2.2                 lubridate_1.5.6             xgboost_0.4-3              
[10] magrittr_1.5                dplyr_0.5.0                 jsonlite_1.0               
[13] httr_1.2.1                  rvdata_0.1.0                RODBC_1.3-12               
[19] XML_3.98-1.4                reshape2_1.4.1              ggplot2_2.1.0              
[22] DT_0.1                      infotheo_1.2.0              RMySQL_0.10.9              
[25] ROCR_1.0-7                  gplots_2.17.0               gtools_3.5.0               
[28] gbm_2.1.1                   lattice_0.20-33             survival_2.38-3            
[31] plyr_1.8.4                  sqldf_0.4-10                RSQLite_1.0.0              
[34] DBI_0.4-1                   gsubfn_0.6-6                proto_0.3-10               
[37] coreFunctions_0.1.0         devtools_1.10.0            

loaded via a namespace (and not attached):
 [1] tcltk_3.2.3        colorspace_1.2-6   htmltools_0.3.5    chron_2.3-47       withr_1.0.1       
 [6] audio_0.1-5        munsell_0.4.3      gtable_0.2.0       caTools_1.17.1     htmlwidgets_0.6   
[11] memoise_1.0.0      curl_0.9.7         Rcpp_0.12.5        KernSmooth_2.23-15 scales_0.4.0      
[16] gdata_2.17.0       digest_0.6.9       stringi_1.1.1      grid_3.2.3         tools_3.2.3       
[21] bitops_1.0-6       tibble_1.1         Matrix_1.2-3       data.table_1.9.6   R6_2.1.2          
[26] git2r_0.13.1 
like image 310
Moderat Avatar asked Jul 20 '16 13:07

Moderat


People also ask

How do I manually install a package in R?

Go into R, click on Packages (at the top of the R console), then click on "Install package(s) from local zip files", then find the zip file with arm from wherever you just saved it. Do the same thing to install each of the other packages you want to install.


Video Answer


1 Answers

From that screenshot, it looks like your package may be on GitHub? Have you been able to use install_github to install a certain release of a package? In that function, you specify a commit/tag/branch with ref, like so:

> library(devtools)
> install_github("hadley/lubridate", ref = "v1.6.0")
Using GitHub PAT from envvar GITHUB_PAT
Downloading GitHub repo hadley/[email protected]
from URL https://api.github.com/repos/hadley/lubridate/zipball/v1.6.0
Installing lubridate
'/Library/Frameworks/R.framework/Resources/bin/R' --no-site-file --no-environ --no-save --no-restore --quiet CMD INSTALL  \
  '/private/var/folders/0w/prb4hnss2gn1p7y34qb2stw00000gp/T/RtmpZcDif6/devtools3b442dfebb82/hadley-lubridate-d986d4b'  \
  --library='/Library/Frameworks/R.framework/Versions/3.3/Resources/library' --install-tests 

* installing *source* package ‘lubridate’ ...
** libs
clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG  -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include    -fPIC  -Wall -mtune=core2 -g -O2  -c datetime.c -o datetime.o
clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG  -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include    -fPIC  -Wall -mtune=core2 -g -O2  -c period.c -o period.o
clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG  -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include    -fPIC  -Wall -mtune=core2 -g -O2  -c tparse.c -o tparse.o
clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG  -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include    -fPIC  -Wall -mtune=core2 -g -O2  -c utils.c -o utils.o
clang -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o lubridate.so datetime.o period.o tparse.o utils.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
installing to /Library/Frameworks/R.framework/Versions/3.3/Resources/library/lubridate/libs
** R
** data
*** moving datasets to lazyload DB
** inst
** tests
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (lubridate)
like image 124
Julia Silge Avatar answered Oct 21 '22 13:10

Julia Silge