Learn R Programming

archivist (version 2.0.2)

aoptions: Default Options for Archivist

Description

The function aoptions sets and gets default options for other archivist functions.

Usage

aoptions(key, value = NULL, unset = FALSE)

Arguments

key
A character denoting name of the parameter.
value
New value for the 'key' parameter.
unset
Set to TRUE if want to set parameter to NULL, i.e. when unsetting Repository aoptions('repoDir', NULL, T).

Value

  • The function returns value that corresponds to a selected key.

Details

The function aoptions with two parameters sets default value of key parameter for other archivist functions. The function aoptions with one parameter returns value (stored in an internal environment)) of the given key parameter.

See Also

Other archivist: Repository, Tags, %a%, addHooksToPrint, addTagsRepo, aformat, ahistory, alink, archivist-package, aread, asearch, asession, cache, copyLocalRepo, createLocalRepo, createMDGallery, deleteLocalRepo, getRemoteHook, getTagsLocal, loadFromLocalRepo, md5hash, restoreLibs, rmFromLocalRepo, saveToLocalRepo, searchInLocalRepo, setLocalRepo, shinySearchInLocalRepo, showLocalRepo, splitTagsLocal, summaryLocalRepo, zipLocalRepo

Examples

Run this code
# data.frame object
# data(iris)


## EXAMPLE 1 : SET default local repository using aoptions() function.

# creating example repository
exampleRepoDir <- tempfile()
createLocalRepo(exampleRepoDir)

# "repodDir" parameter in each archivist function will be default and set to exampleRepoDir.
aoptions(key = "repoDir", value = exampleRepoDir)

data(iris)
data(swiss)
# From this moment repoDir parameter may be ommitted in the following functions
saveToLocalRepo(iris)
saveToLocalRepo(swiss) 
showLocalRepo()
showLocalRepo(method = "tags")
zipLocalRepo()
file.remove(file.path(getwd(), "repository.zip"))
iris2 <- loadFromLocalRepo( "ff575c2" , value = TRUE)
searchInLocalRepo("name:i", fixed = F)
getTagsLocal("ff575c261c949d073b2895b05d1097c3")
rmFromLocalRepo("4c43f")
showLocalRepo()
summaryLocalRepo()

# REMEMBER that in deleteRepo you MUST specify repoDir parameter!
# deleteLocalRepo doesn't take setLocalRepo's settings into consideration
deleteLocalRepo( exampleRepoDir, deleteRoot = TRUE)
rm( exampleRepoDir )

## EXAMPLE 2 : SET default Github repository using aoptions() function.
aoptions(key = "user", value = "pbiecek")
aoptions(key = "repo", value = "archivist")

# From this moment user and repo parameters may be ommitted in the following functions:
showRemoteRepo() 
loadFromRemoteRepo( "ff575c261c949d073b2895b05d1097c3")
this <- loadFromRemoteRepo( "ff", value = T)
file.remove(file.path(getwd(), "repository.zip")) # We can remove this zip file
searchInRemoteRepo( "name:", fixed= FALSE)
getTagsGithub("ff575c261c949d073b2895b05d1097c3")
summaryRemoteRepo( )
searchInRemoteRepo( pattern=c("varname:Sepal.Width", "class:lm", "name:myplot123"), 
                         intersect = FALSE ) 
## EXAMPLE 3 : SET default Github repository using aoptions() function.
showRemoteRepo('Museum', 'MarcinKosinski', subdir = 'ex1')
aoptions('repo', 'Museum')
aoptions('user', 'MarcinKosinski')
aoptions('subdir', 'ex1')
aoptions('branch', 'master')
showRemoteRepo()
showRemoteRepo(subdir = 'ex2')

aoptions('subdir')

Run the code above in your browser using DataLab