Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upainstall #251
ainstall #251
Comments
|
Cool idea, but I am not sure if it's possible for github packages or own 2016-02-17 16:06 GMT+01:00 Marcin Kosiński notifications@github.com:
pozdrawiam serdecznie, |
|
Or we can add a note to |
|
|
I went with devtools::install_version (but it does not support check this out # Recreate packages library for artifact
Marcin Kosiński
27 lutego 2016
# Retrieve object created with archive-version of ggplot2
```r
library(devtools)
install.packages('ggplot2', repos = 'https://cran.rstudio.com/')
library(ggplot2)
devtools::session_info(pkgs = 'ggplot2')adir <- 'adir'
dir.create(adir)
.libPaths(c(adir, .libPaths())) # lib argument in devtools does not work
install.packages('devtools', repos = 'https://cran.rstudio.com/')
devtools::install_version('ggplot2', version = '1.0.1', lib = adir, repos = 'https://cran.rstudio.com/')
library(ggplot2, lib = adir)
devtools::session_info('ggplot2')arecreate()library(archivist)
system.file('graphGallery', package = 'archivist') -> archivist.dir
setLocalRepo(archivist.dir)
arecreate.dir <- 'arecreate.dir'
dir.create('arecreate.dir')
arecreate <- function(md5hash = '600bda83cb840947976bd1ce3a11879d', lib, repos = 'https://cran.rstudio.com/' ){
old_lib <- .libPaths()
new_lib <- .libPaths(lib)
# probably local installations or GitHub packages
NOT_CRAN <- which(asession(md5hash)$packages[, '*'] == '*')
CRAN_PKGS <- grep('CRAN',
x = asession(md5hash)$packages[, 'source'])
GITHUB_PKGS <- grep('Github',
x = asession(md5hash)$packages[, 'source'])
# reinstall CRAN packages
sapply(setdiff(CRAN_PKGS, NOT_CRAN), function(package){
devtools::install_version(asession(md5hash)$packages[package, 'package'],
version = asession(md5hash)$packages[package, 'version'],
lib = lib, repos = repos )
})
# extract commits and names from parenthesis
gsub("[\\(\\)]",
"",
regmatches(asession(md5hash)$packages[GITHUB_PKGS, 'source'],
gregexpr("\\(.*?\\)",
asession(md5hash)$packages[GITHUB_PKGS, 'source'])
)[[1]]
) -> GITHUB_NAMES
# reinstall GitHub packages
devtools::install_github(GITHUB_NAMES, lib = lib)
.libPaths(old_lib)
}
arecreate('600bda83cb840947976bd1ce3a11879d', lib = arecreate.dir)knitr::kable(installed.packages(arecreate.dir))
|
|
There is a lot of calls to But larger problem is that it is not working on OSX ;-)
You need to add I will do more tests in a few days |
|
I was thinking about other possible names fir this function. |
|
libraryRestore? arestore? 2016-02-28 23:47 GMT+01:00 Przemysław Biecek notifications@github.com:
|
|
It will work, I like libraryRestore more, since the name is more self explanatory, |
|
I've added restoreLibs() function. There are some dirty solutions, so I will think more about alternatives. But at least it is working for ggplot2 objects |
|
I've added devtools check - if it is installed - since we do not have imports from devtools 400216c |
|
By now If that's ok for you additional example to old_lib <- .libPaths()
new_lib <- .libPaths(new_directory)
restoreLibs()
.libPaths(old_lib)
|
|
It will be a good solution and I saw it in your proposition 2016-03-05 18:37 GMT+01:00 Marcin Kosiński notifications@github.com:
pozdrawiam serdecznie, |
|
Could you provide a reproducible example of that situation on OSX? .libPaths() -> x
x
.libPaths(tempfile()) -> y
y
.libPaths(x)
I'll post that case on StackOverflow 2016-03-05 20:07 GMT+01:00 Przemysław Biecek notifications@github.com:
|
|
Here it is
|
|
Ok, but now I see where is the problem
|
|
Yes, that's the case. But I still have problems here 2016-03-05 21:00 GMT+01:00 Przemysław Biecek notifications@github.com:
|
for a specific md5hash,
asessiongives packages and versions under which it was created, maybe one should createainstallfunction that install specific versions of R packages with the usage of this package https://cran.r-project.org/web/packages/versions/index.html