# NOT RUN {
### default LOCAL version
## objects preparation
# data.frame object
data(iris)
# ggplot/gg object
library(ggplot2)
df <- data.frame(gp = factor(rep(letters[1:3], each = 10)),y = rnorm(30))
library(plyr)
ds <- ddply(df, .(gp), summarise, mean = mean(y), sd = sd(y))
myplot123 <- ggplot(df, aes(x = gp, y = y)) +
geom_point() + geom_point(data = ds, aes(y = mean),
colour = 'red', size = 3)
# lm object
model <- lm(Sepal.Length~ Sepal.Width + Petal.Length + Petal.Width, data= iris)
model2 <- lm(Sepal.Length~ Sepal.Width + Petal.Width, data= iris)
model3 <- lm(Sepal.Length~ Sepal.Width, data= iris)
## creating example default local repository
exampleRepoDir <- tempfile()
createLocalRepo(repoDir = exampleRepoDir)
## setting default local repository
setLocalRepo( repoDir = exampleRepoDir )
saveToLocalRepo(myplot123)
saveToLocalRepo(iris)
saveToLocalRepo(model)
saveToLocalRepo(model2)
saveToLocalRepo(model3)
## Searching for objects of class:lm
lm <- asearch(patterns = "class:lm")
## Searching for objects of class:lm with coefname:Petal.Width
lm_c_PW <- asearch(patterns = c("class:lm","coefname:Petal.Width"))
# Note that we searched for objects. Then loaded them from repository by their value.
## deleting example repository
deleteLocalRepo(repoDir = exampleRepoDir, deleteRoot = TRUE)
rm(exampleRepoDir)
### default GitHub version
## Setting default github repository
setRemoteRepo( user = "pbiecek", repo = "archivist")
showRemoteRepo(method = "tags")$tag
searchInRemoteRepo(pattern = "class:lm")
searchInRemoteRepo(pattern = "class:gg")
getTagsRemote(md5hash = "cd6557c6163a6f9800f308f343e75e72", tag = "")
## Searching for objects of class:lm
asearch(patterns = c("class:lm"))
## Searching for objects of class:gg
ggplot_objects <- asearch(patterns = c("class:gg"))
# names(ggplot_objects)
# To plot them remember to have ggplot2 in version 2.1.0
# as this is stated in asession("pbiecek/archivist/13b2724139eb2c62578b4dab0d7b2cea") or
asession("pbiecek/archivist/7f3453331910e3f321ef97d87adb5bad") .
# The state of R libraries can be restored to the same state in
# which those objects were created with the restoreLibs function.
### Remote version
## Note that repo argument is passed in the following way to asearch:
## repo = "GitHub user name/GitHub repository name"
## Searching for objects of class:gg
asearch("pbiecek/graphGallery",
patterns = c("class:gg",
"labelx:Sepal.Length")) -> ggplots_objects_v2
# }
Run the code above in your browser using DataLab