Skip to content

Commit

Permalink
shorten examples in delete and create #198 #210
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcinKosinski committed Feb 7, 2016
1 parent 14cd166 commit 4e3b767
Show file tree
Hide file tree
Showing 35 changed files with 127 additions and 436 deletions.
4 changes: 1 addition & 3 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@ export(asession)
export(cache)
export(copyLocalRepo)
export(copyRemoteRepo)
export(createEmptyLocalRepo)
export(createEmptyRepo)
export(createLocalRepo)
export(createMDGallery)
export(deleteLocalRepo)
export(deleteRepo)
export(getRemoteHook)
export(getTagsLocal)
export(getTagsRemote)
Expand Down
43 changes: 7 additions & 36 deletions R/createEmptyRepo.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
#' @title Create an Empty Repository
#'
#' @description
#' \code{createEmptyLocalRepo} creates an empty \link{Repository} in the given directory in which archived artifacts will be stored.
#' \code{createEmptyRepo} is a wrapper around \code{createEmptyLocalRepo} to maintain consistency with the previous \pkg{archivist} versions (<1.8.6.0)
#' where there was only \code{createEmptyRepo} which created Local \code{Repository}.
#' \code{createLocalRepo} creates an empty \link{Repository} in the given directory in which archived artifacts will be stored.
#'
#' @details
#' At least one Repository must be initialized before using other functions from the \pkg{archivist} package.
Expand Down Expand Up @@ -47,39 +45,16 @@
#' @examples
#' \dontrun{
#' exampleRepoDir <- tempfile()
#' createEmptyRepo( repoDir = exampleRepoDir )
#'
#' # check the state of an empty Repository
#'
#' summaryLocalRepo( repoDir = exampleRepoDir )
#' showLocalRepo( exampleRepoDir )
#'
#' # creating a Repository in non existing directory
#'
#' createEmptyLocalRepo( "xyzdd234") # force = TRUE is default argument
#'
#' # creating a default local Repository in non existing directory
#'
#' createEmptyRepo("def", default = TRUE)
#' createEmptyRepo( repoDir = exampleRepoDir, default = TRUE )
#' data(iris)
#' saveToRepo(iris) # We don't have to specify repoDir parameter
#' showLocalRepo() # because repoDir="def" is default
#'
#' # removing an example Repositories
#'
#' deleteRepo( exampleRepoDir, TRUE)
#' deleteRepo( "xyzdd234", TRUE)
#' deleteRepo("def", TRUE)
#'
#' rm( exampleRepoDir )
#'
#'
#' }
#' saveToRepo(iris)
#' showLocalRepo()
#' showLocalRepo(method = "tags")
#' deleteLocalRepo( repoDir = exampleRepoDir, unset = TRUE, deleteRoot = TRUE)
#' @family archivist

#' @rdname createEmptyRepo
#' @export
createEmptyLocalRepo <- function( repoDir, force = TRUE, default = FALSE ){
createLocalRepo <- function( repoDir, force = TRUE, default = FALSE ){
stopifnot( is.character( repoDir ), length( repoDir ) == 1 )
stopifnot( is.logical( default ), length( default ) == 1 )

Expand Down Expand Up @@ -128,10 +103,6 @@ createEmptyLocalRepo <- function( repoDir, force = TRUE, default = FALSE ){

}

#' @rdname createEmptyRepo
#' @export
createEmptyRepo <- createEmptyLocalRepo

addArtifact <- function( md5hash, name, dir ){
# creates connection and driver
# send insert
Expand Down
136 changes: 7 additions & 129 deletions R/deleteRepo.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#' @title Delete the Existing Repository from the Given Directory
#'
#' @description
#' \code{deleteRepo} deletes the existing \link{Repository} from the given directory.
#' \code{deleteLocalRepo} deletes the existing \link{Repository} from the given directory.
#' As a result all artifacts from \code{gallery} folder are removed and database \code{backpack.db}
#' is deleted.
#'
Expand All @@ -14,16 +14,10 @@
#' @param unset A logical. If deleted \code{repoDir/repo} was set to be default Local/GitHub Repository
#' and \code{unset} is TRUE, then \code{repoDir/repo} is unset as a default Local/GitHub Repository (\code{aoptions('repoDir/repo', NULL, T)}).
#'
#' @details
#'
#' Since version 1.9 \code{deleteRepo} is a wrapper around \code{deleteLocalRepo} (in earlier versions deleteRepo) and \link[archivist.github]{deleteGitHubRepo}
#' functions and by default triggers \code{deleteLocalRepo} to maintain consistency with the previous \pkg{archivist} versions (<1.9.0)
#' where there was only \code{deleteRepo} which deleted local \code{Repository}.
#'
#' @note
#' Remember that using \code{tempfile()} instead of \code{tempdir()}
#' in examples section is crucial. \code{tempdir()} is existing directory
#' in which R works so calling \code{deleteRepo(exampleRepoDir, deleteRoot=TRUE)}
#' in which R works so calling \code{deleteLocalRepo(exampleRepoDir, deleteRoot=TRUE)}
#' removes important R files. You can find out more information about this problem at
#' \href{http://stackoverflow.com/questions/22325820/unlink-function-causing-an-error-for-consequent-and-plot-functions}{stackoverflow}
#' webpage.
Expand All @@ -32,127 +26,15 @@
#' Marcin Kosinski, \email{m.p.kosinski@@gmail.com}
#'
#' @examples
#' \dontrun{
#'
#' ########################
#' #### 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)
#'
#' # 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)
#'
#' # lda object
#' library(MASS)
#'
#' Iris <- data.frame(rbind(iris3[,,1], iris3[,,2], iris3[,,3]),
#' Sp = rep(c("s","c","v"), rep(50,3)))
#' train <- c(8,83,115,118,146,82,76,9,70,139,85,59,78,143,68,
#' 134,148,12,141,101,144,114,41,95,61,128,2,42,37,
#' 29,77,20,44,98,74,32,27,11,49,52,111,55,48,33,38,
#' 113,126,24,104,3,66,81,31,39,26,123,18,108,73,50,
#' 56,54,65,135,84,112,131,60,102,14,120,117,53,138,5)
#' lda1 <- lda(Sp ~ ., Iris, prior = c(1,1,1)/3, subset = train)
#'
#' # qda object
#' tr <- c(7,38,47,43,20,37,44,22,46,49,50,19,4,32,12,29,27,34,2,1,17,13,3,35,36)
#' train <- rbind(iris3[tr,,1], iris3[tr,,2], iris3[tr,,3])
#' cl <- factor(c(rep("s",25), rep("c",25), rep("v",25)))
#' qda1 <- qda(train, cl)
#'
#' # glmnet object
#' library( glmnet )
#'
#' zk=matrix(rnorm(100*20),100,20)
#' bk=rnorm(100)
#' glmnet1=glmnet(zk,bk)
#'
#'
#' # creating example Repository - on which examples will work
#'
#' # save examples
#'
#' exampleRepoDir <- tempfile()
#' createEmptyRepo( repoDir = exampleRepoDir )
#' saveToRepo( myplot123, repoDir=exampleRepoDir )
#' saveToRepo( iris, repoDir=exampleRepoDir )
#' saveToRepo( model, repoDir=exampleRepoDir )
#' saveToRepo( agn1, repoDir=exampleRepoDir )
#' saveToRepo( fannyx, repoDir=exampleRepoDir )
#' saveToRepo( lda1, repoDir=exampleRepoDir )
#' saveToRepo( qda1, repoDir=exampleRepoDir )
#' saveToRepo( glmnet1, repoDir=exampleRepoDir )
#'
#'
#' # let's see how the Repository looks like: show
#'
#' showLocalRepo( method = "md5hashes", repoDir = exampleRepoDir )
#' showLocalRepo( method = "tags", repoDir = exampleRepoDir )
#'
#' # let's get information about that Repository
#'
#' summaryLocalRepo( repoDir = exampleRepoDir )
#'
#' # now let's delete the Repository without it's root
#'
#' deleteRepo( repoDir = exampleRepoDir)
#'
#' rm( exampleRepoDir )
#'
#' ## Using deleteRoot = TRUE argument
#'
#' # First we create default Repository on our computer
#' createEmptyRepo( repoDir = "defRepo", force = TRUE, default = TRUE )
#' saveToRepo( myplot123)
#' saveToRepo( iris)
#' saveToRepo( model)
#'
#' # Let's see how the Repository looks like: show
#'
#' showLocalRepo( method = "md5hashes")
#' showLocalRepo( method = "tags")
#'
#' # Let's get information about that Repository
#'
#' summaryLocalRepo()
#'
#' # Now let's delete the Repository and it's root folder by using
#' # deleteRoot = TRUE argument
#'
#' deleteRepo(repoDir = "defRepo", deleteRoot = TRUE)
#' # defRepo was completely deleted indeed! We may notice it on our computer.
#' #
#' # or if aoptions('repodir') == repodir then
#' # deleteRepo(repoDir, deleteRoot = TRUE, unset = TRUE)
#'
#' }
#' createEmptyRepo( repoDir = exampleRepoDir, default = TRUE )
#' data(iris)
#' saveToRepo(iris)
#' deleteLocalRepo( repoDir = exampleRepoDir, unset = TRUE, deleteRoot = TRUE)
#'
#' @family archivist

#' @rdname deleteRepo
#' @rdname deleteLocalRepo
#' @export
deleteLocalRepo <- function(repoDir, deleteRoot = FALSE, unset = FALSE){
stopifnot( is.character( repoDir ), length( repoDir ) == 1 )
Expand All @@ -178,7 +60,3 @@ deleteLocalRepo <- function(repoDir, deleteRoot = FALSE, unset = FALSE){

}

#' @rdname deleteRepo
#' @export
deleteRepo <- deleteLocalRepo

2 changes: 1 addition & 1 deletion man/Repository.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/Tags.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/addHooksToPrint.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/addTagsRepo.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/aformat.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/ahistory.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/alink.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/archivist-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/archivistOptions.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/aread.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/asearch.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/asession.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/cache.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/copyToRepo.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 4e3b767

Please sign in to comment.