archivist (version 1.2)

searchInLocalRepo: Search for an Artifact in a Repository Using Tags

Description

searchInRepo searches for an artifact in a Repository using it's Tags. To learn more about artifacts visit archivist-package.

Usage

searchInLocalRepo(pattern, repoDir, fixed = TRUE, realDBname = TRUE)

searchInGithubRepo(pattern, repo, user, branch = "master", repoDirGit = FALSE, fixed = TRUE)

multiSearchInLocalRepo(patterns, repoDir, fixed = TRUE, intersect = TRUE, realDBname = TRUE)

multiSearchInGithubRepo(patterns, repo, user, branch = "master", repoDirGit = FALSE, fixed = TRUE, intersect = TRUE)

Arguments

pattern
If fixed = TRUE: a character denoting a Tags to be searched for in the Repository. It is also possible to specify pattern as a list of length 2 with dataFrom and dataTo<
repoDir
A character denoting an existing directory in which artifacts will be searched.
fixed
A logical value specifying how artifacts should be searched for. If fixed = TRUE (default) then artifacts are searched exactly to the corresponding pattern parameter. If fixed = FALSE then artifa
realDBname
A logical value. Should not be changed by user. It is a technical parameter.
repo
Only if working with a Github repository. A character containing a name of a Github repository on which the Repository is archived.
user
Only if working with a Github repository. A character containing a name of a Github user on whose account the repo is created.
branch
Only if working with a Github repository. A character containing a name of Github repository's branch in which Repository is archived. Default branch is master.
repoDirGit
Only if working with a Github repository. A character containing a name of a directory on Github repository on which the Repository is stored. If the Repository is stored in main folder on Github repository, this should be set to repoDirGit
patterns
A vector of queries to repository. If intersect = TRUE only artifacts that match all conditions are returned. If intersect = FALSE then artifacts that match any contition are returned.
intersect
A logical value. See patterns for more details.

Value

  • searchInRepo returns a md5hash character, which is a hash assigned to the artifact when saving it to the Repository by using the saveToRepo function. If the artifact is not in the Repository a logical value FALSE is returned.

Details

searchInRepo searches for an artifact in a Repository using it's Tag (e.g., name, class or archiving date). Tags are submitted in a pattern argument. For various artifact classes different Tags can be searched for. See Tags. If a pattern is a list of length 2, md5hashes of all artifacts created from date dateFrom to data dateTo are returned. The date should be formatted according to the YYYY-MM-DD format, e.g., "2014-07-31".

Tags, submitted in a pattern argument, should be given according to the format: "TagType:TagTypeValue" - see examples.

See Also

Other archivist: Repository; Tags; addTagsRepo; archivist-package; cache; copyGithubRepo, copyLocalRepo; createEmptyRepo; deleteRepo; getTagsGithub, getTagsLocal; loadFromGithubRepo, loadFromLocalRepo; md5hash; rmFromRepo; saveToRepo; shinySearchInLocalRepo; showGithubRepo, showLocalRepo; summaryGithubRepo, summaryLocalRepo; zipGithubRepo, zipLocalRepo

Examples

Run this code
# 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)

  # agnes (twins) object
  library(cluster)
  data(votes.repub)
  agn1 <- agnes(votes.repub, metric = "manhattan", stand = TRUE)

  # fanny (partition) object
  x <- rbind(cbind(rnorm(10, 0, 0.5), rnorm(10, 0, 0.5)),
             cbind(rnorm(15, 5, 0.5), rnorm(15, 5, 0.5)),
             cbind(rnorm( 3,3.2,0.5), rnorm( 3,3.2,0.5)))
  fannyx <- fanny(x, 2)

  # creating example Repository - that examples will work

  exampleRepoDir <- tempdir()
  createEmptyRepo(repoDir = exampleRepoDir)
  saveToRepo(myplot123, repoDir=exampleRepoDir)
  saveToRepo(iris, repoDir=exampleRepoDir)
  saveToRepo(model, repoDir=exampleRepoDir)
  saveToRepo(agn1, repoDir=exampleRepoDir)
  saveToRepo(fannyx, repoDir=exampleRepoDir)

  # let's see how the Repository look like: show

  showLocalRepo(method = "md5hashes", repoDir = exampleRepoDir)
  showLocalRepo(method = "tags", repoDir = exampleRepoDir)

  # let's see how the Repository look like: summary

  summaryLocalRepo( exampleRepoDir )


  # search examples

  # tag search, fixed version
  searchInLocalRepo( "class:ggplot", repoDir = exampleRepoDir )
  searchInLocalRepo( "name:myplot123", repoDir = exampleRepoDir )
  searchInLocalRepo( "varname:Sepal.Width", repoDir = exampleRepoDir )
  searchInLocalRepo( "class:lm", repoDir = exampleRepoDir )
  searchInLocalRepo( "coefname:Petal.Length", repoDir = exampleRepoDir )
  searchInLocalRepo( "ac:0.797755535467609", repoDir = exampleRepoDir )

  # tag search, regex version

  searchInLocalRepo( "class", repoDir = exampleRepoDir, fixed = FALSE )
  searchInLocalRepo( "name", repoDir = exampleRepoDir, fixed = FALSE )

  # Github version
  # check the state of the Repository
  summaryGithubRepo( user="pbiecek", repo="archivist" )
  showGithubRepo( user="pbiecek", repo="archivist" )
  showGithubRepo( user="pbiecek", repo="archivist", method = "tags" )

  # tag search, fixed version
  searchInGithubRepo( "varname:Sepal.Width", user="pbiecek", repo="archivist" )
  searchInGithubRepo( "class:lm", user="pbiecek", repo="archivist", branch="master" )
  searchInGithubRepo( "name:myplot123", user="pbiecek", repo="archivist" )

  # tag search, regex version
  searchInGithubRepo( "class", user="pbiecek", repo="archivist",  fixed = FALSE )
  searchInGithubRepo( "name", user="pbiecek", repo="archivist", fixed = FALSE )


  # date search

  # objects archivised between 2 different days
  searchInLocalRepo( pattern = list( dateFrom = Sys.Date()-1, dateTo = Sys.Date()+1),
                     repoDir = exampleRepoDir )

  # also on Github

  searchInGithubRepo( pattern = list( dateFrom = "2014-09-01", dateTo = "2014-09-30" ),
                      user="pbiecek", repo="archivist", branch="master" )


  # objects from Today
  searchInLocalRepo( pattern = list( dateFrom=Sys.Date(), dateTo=Sys.Date() ),
                     repoDir = exampleRepoDir )

  # removing an example Repository

  deleteRepo( exampleRepoDir )

  rm( exampleRepoDir )

  # many archivist-like Repositories on one Github repository

  searchInGithubRepo( pattern = "name", user="MarcinKosinski", repo="Museum",
  branch="master", repoDirGit="ex1", fixed = FALSE )

  searchInGithubRepo( pattern = "name", user="MarcinKosinski", repo="Museum",
                   branch="master", repoDirGit="ex2", fixed = FALSE )

Run the code above in your browser using DataCamp Workspace