The graph below presents the evolution of number of casualties in road accidents in selected european countries. The graph is based on data from eurostat.
Now consider two options:
It some cases one may just need to access the object / table / plot / statsitical model.
The archivist is package that allows to share, store, restore and look for R objects in local or github repositories.
The plot presented above is avaliable in my github repositorypbiecek/graphGalleryas an object with id
fcd70d55b874201d2bece12f591a2ec4
. How to access it?
library(archivist)
pl <- loadFromGithubRepo( md5hash = "fcd70d55b874201d2bece12f591a2ec4" ,
user = "pbiecek", repo = "graphGallery", value=TRUE)
The object
pl
is ready to be plotted.
So it is easy to access objects created by others, but is it easy to make the object accessible?
Let’s start with creation of an object that we would like to share.
library(ggplot2)
library(dplyr)
if (!require(eurostat)) {
install_github("rOpenGov/eurostat")
}
t1 <- get_eurostat("tsdtr420") %>%
filter(geo %in% c("UK", "SK", "FR", "PL", "ES", "PT", "LV"))
pl <- ggplot(t1, aes(x = time, y = value, color=geo, group=geo, shape=geo)) +
geom_point(size=4) +
geom_line() + theme_bw() + ggtitle("People killed in road accidents")
Now let’s prepare a local repository.
createEmptyRepo("graphGallery", force = TRUE)
The function
saveToRepo
will save an object into the repository, extracts useful elements from the object (like the dataset) and save separatly plot and it’s data in the repository. As an result it retuns keys / md5hashes of both objects.
saveToRepo(artifact = pl, repoDir = "graphGallery")
## [1] "de9a3ac2624e16d02c7596e39f69b2bd"
## attr(,"data")
## [1] "e529c9447db30766e216e8fff7adaf2a"