我有一个带有辅助函数的个人R包,我在各种项目中使用它。但是,我想让项目使用特定版本的项目,然后继续添加代码。我知道我可以用分支机构做到这一点,但我更喜欢用提交标签来做。
查看devtools::install_git
的文档,似乎如果我标记了一个提交,那么我应该能够安装该特定提交,但这对我不起作用。
但是试图安装它给了我这个:
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
我的R会话信息:
> 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
答案 0 :(得分:1)
从截图中看,您的软件包可能在GitHub上?您是否能够使用install_github
安装某个软件包的某个版本?在该函数中,您使用ref
指定提交/标记/分支,如下所示:
> library(devtools)
> install_github("hadley/lubridate", ref = "v1.6.0")
Using GitHub PAT from envvar GITHUB_PAT
Downloading GitHub repo hadley/lubridate@v1.6.0
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)