trinker / pacman

A package management tools for R
311 stars 37 forks source link

p_base #11

Open Dasonk opened 12 years ago

Dasonk commented 12 years ago

I'm confused on what p_base is supposed to do. Can you provide some explanation?

trinker commented 12 years ago

I created p_base to be the counterpart to p_library. It shows what packages are in the folder that are part of the standard R install. It also prints asterisks on the base packages that load when R starts. I altered the function to print this list of base packages with asterisks but the function actually silently returns the non asterisked vector of base packages. This makes it more usable.

I don't see this as a hugely used function but wanted to make it as I've had the need to see those packages from time to time. If the argument open is TRUE then the directory location of these packages should open. This works on Windows but didn't seem to on Ubuntu.

Try this to see what it does:

p_base()       #prints the unquoted list of base packages
.Last.value    #actually invisibly returned the vector (no asterisks)
p_base(TRUE)   #opens base directory
Dasonk commented 12 years ago

I guess I'm wondering what you mean by the base install. Because currently p_base returns almost the same thing as p_lib() for me. It looks like we're just grabbing the second item from .libPaths but there isn't much reason to believe that that is going to be the folder for the 'base' install stuff.

trinker commented 12 years ago

Oh I assumed it was. I don't know how to fix that. For me the first folder is the add on packages and the second folder is the base install packages. So for me the call to p_base gives this:


packages with an "***" are loaded when R starts

 [1] base ***      boot          class         cluster       codetools    
 [6] compiler      datasets ***  foreign       graphics ***  grDevices ***
[11] grid          KernSmooth    lattice       MASS          Matrix       
[16] methods ***   mgcv          nlme          nnet          parallel     
[21] rpart         spatial       splines       stats ***     stats4       
[26] survival      tcltk         tools         utils ***    

maybep_base and p_library need to become one function. Asterisks could be something like:

* for base install
*** for base install the loads when R starts up
Dasonk commented 12 years ago

This is my output:

> p_base()

packages with an "***" are loaded when R starts

  [1] "akima"            "animation"        "annotate"        
  [4] "AnnotationDbi"    "ascii"            "aws"             
  [7] "awsMethods"       "base ***"         "baySeq"          
 [10] "Biobase"          "BiocGenerics"     "BiocInstaller"   
 [13] "bitops"           "boot"             "brew"            
 [16] "cairoDevice"      "caTools"          "chron"           
 [19] "class"            "cluster"          "coda"            
 [22] "codetools"        "colorspace"       "compiler"        
 [25] "datasets ***"     "DBI"              "DESeq"           
 [28] "devtools"         "dichromat"        "digest"          
 [31] "dlm"              "DPpackage"        "edgeR"           
 [34] "evaluate"         "flexmix"          "foreign"         
 [37] "formatR"          "fortunes"         "fun"             
 [40] "gdata"            "genefilter"       "geneplotter"     
 [43] "geoR"             "GGally"           "ggmap"           
 [46] "ggplot2"          "gmp"              "gplots"          
 [49] "graphics ***"     "grDevices ***"    "grid"            
 [52] "gridExtra"        "gsubfn"           "gtools"          
 [55] "gWidgets"         "gWidgetsRGtk2"    "highlight"       
 [58] "inline"           "int64"            "IRanges"         
 [61] "kernlab"          "KernSmooth"       "knitr"           
 [64] "labeling"         "lattice"          "LearnBayes"      
 [67] "limma"            "locfit"           "lubridate"       
 [70] "mapproj"          "maps"             "MASS"            
 [73] "Matrix"           "MCMCpack"         "memoise"         
 [76] "methods ***"      "mgcv"             "minqa"           
 [79] "modeltools"       "msm"              "multcomp"        
 [82] "munsell"          "mvtnorm"          "nlme"            
 [85] "nnet"             "openNLP"          "openNLPmodels.en"
 [88] "pacman"           "parallel"         "parser"          
 [91] "partitions"       "plyr"             "png"             
 [94] "polynom"          "pracma"           "productplots"    
 [97] "proto"            "qdap"             "quandis"         
[100] "qvalue"           "R.basic"          "R.methodsS3"     
[103] "R.oo"             "R.utils"          "RandomFields"    
[106] "rbenchmark"       "RColorBrewer"     "Rcpp"            
[109] "RcppEigen"        "RCurl"            "reshape"         
[112] "reshape2"         "RgoogleMaps"      "RGtk2"           
[115] "rj"               "rj.gd"            "rJava"           
[118] "rjson"            "RJSONIO"          "roxygen2"        
[121] "rpart"            "RSQLite"          "RSQLite.extfuns" 
[124] "Rstem"            "rvmbinary"        "RWeka"           
[127] "RWekajars"        "scales"           "slam"            
[130] "Snowball"         "sos"              "sp"              
[133] "spatial"          "splancs"          "splines"         
[136] "sqldf"            "stats ***"        "stats4"          
[139] "stringr"          "survival"         "tcltk"           
[142] "TeachingDemos"    "tm"               "tools"           
[145] "TTR"              "twitteR"          "utils ***"       
[148] "venneuler"        "VGAM"             "wordcloud"       
[151] "xlsx"             "xlsxjars"         "XML"             
[154] "xtable"           "xts"              "zoo" 
Dasonk commented 12 years ago

Well I don't think there is much we can do about pretty much everything being installed into that folder for me but I did make detection of the base folder more robust. I'm closing this for the time being.

trinker commented 12 years ago

It looks like we're just grabbing the second item from .libPaths but there isn't much reason to believe that that is going to be the folder for the 'base' install stuff. -Dason-

This really is an issue across the boards in many functions. For instance p_delete is:

> p_delete
function (...) 
{
    mf <- match.call(expand.dots = FALSE)
    x <- as.character(mf[[2]])
    lp <- .libPaths()[1]
    z <- x[!x %in% dir(lp)]
    m <- dir(.libPaths()[2])
    o <- z[z %in% dir(.libPaths()[2])]
    z <- z[!z %in% dir(.libPaths()[2])]
    y <- x[x %in% dir(lp)]
    y2 <- paste0("package:", y)
    w <- y %in% names(sessionInfo()[["otherPkgs"]])
    if (any(w)) {
        u <- y2[w]
        invisible(lapply(u, function(package) {
            suppressWarnings(detach(package, character.only = TRUE, 
                force = TRUE, unload = TRUE))
        }))
    }
    if (length(y) > 0) {
        suppressWarnings(remove.packages(y, lib = lp))
    }
    y <- paste(y, collapse = ", ")
    if (!identical(o, character(0))) {
        cat(paste0("The following packages are a base ", "install and will not be deleted:\n"), 
            paste0("\b", paste(o, collapse = ", ")), "\n\n")
    }
    if (!identical(z, character(0))) {
        cat("The following packages not found in library:\n", 
            paste0("\b", paste(z, collapse = ", ")), "\n\n")
    }
    if (length(y) > 0) {
        cat("The following packages have been deleted:\n", paste0("\b", 
            paste(y, collapse = ", ")), "\n")
    }
}
<environment: namespace:pacman>

This is something that must be fixed across multiple functions.

Dasonk commented 12 years ago

I've noticed that - you'll probably have noticed that I haven't done too much with p_help, p_install, and p_delete mainly because they're the bigger ones and I haven't had the time to invest to understand what you were doing with them. But a rewrite for them is probably in order using more descriptive names and moving some functionality to external (non-exported) functions if necessary.

On Thu, Jun 14, 2012 at 11:32 AM, tyler rinker < reply@reply.github.com

wrote:

It looks like we're just grabbing the second item from .libPaths but there isn't much reason to believe that that is going to be the folder for the 'base' install stuff. -Dason-

This really is an issue across the boards in many functions. For instance p_delete is:

> p_delete
function (...)
{
   mf <- match.call(expand.dots = FALSE)
   x <- as.character(mf[[2]])
   lp <- .libPaths()[1]
   z <- x[!x %in% dir(lp)]
   m <- dir(.libPaths()[2])
   o <- z[z %in% dir(.libPaths()[2])]
   z <- z[!z %in% dir(.libPaths()[2])]
   y <- x[x %in% dir(lp)]
   y2 <- paste0("package:", y)
   w <- y %in% names(sessionInfo()[["otherPkgs"]])
   if (any(w)) {
       u <- y2[w]
       invisible(lapply(u, function(package) {
           suppressWarnings(detach(package, character.only = TRUE,
               force = TRUE, unload = TRUE))
       }))
   }
   if (length(y) > 0) {
       suppressWarnings(remove.packages(y, lib = lp))
   }
   y <- paste(y, collapse = ", ")
   if (!identical(o, character(0))) {
       cat(paste0("The following packages are a base ", "install and will
not be deleted:\n"),
           paste0("\b", paste(o, collapse = ", ")), "\n\n")
   }
   if (!identical(z, character(0))) {
       cat("The following packages not found in library:\n",
           paste0("\b", paste(z, collapse = ", ")), "\n\n")
   }
   if (length(y) > 0) {
       cat("The following packages have been deleted:\n", paste0("\b",
           paste(y, collapse = ", ")), "\n")
   }
}
<environment: namespace:pacman>

This is something that must be fixed across multiple functions.


Reply to this email directly or view it on GitHub: https://github.com/trinker/pacman/issues/11#issuecomment-6333637

Dasonk commented 12 years ago

It would probably be easiest if we made functions to install single packages and delete single packages - the logic is easier to follow. Then we can manually set up a function to take multiple inputs to do the installation and/or deletion and call the functions that do one at a time. It's more of the R way to do things vectorized right from the start but I think the logic is easiest to follow when installing/deleting a single package.

trinker commented 10 years ago

We use the following for p_base_path:

p_basepath <- function(){
    file.path(Sys.getenv("R_HOME"), "library")
}

This seems pretty safe but is the following safer:

p_basepath <- function(){
    dirname(system.file(package = "base"))
}

I think once this is addressed we can close this issue?

PS when I said:

If Dason approves of the print method approach it should probably be used with other functions like p_load

I meant functions that have a bunch of messages being printed. I will also add a quiet parameter to many functions where this makes sense.

But in looking at our rewrite of p_load this is no longer necessary.

trinker commented 10 years ago

p_base states:

List all the packages and marks those in a base install.

So I believe lattice would be included in this. It currently is not. I think we either need to change the function description or the code. It makes more sense to change the description. I'm lacking words though. Thoughts???