R 2.14 - detect packages without namespace

后端 未结 3 1883
谎友^
谎友^ 2021-02-07 04:59

According to the R News for v2.14:

All packages must have a namespace, and one is created on installation if not supplied in the sources. This me

相关标签:
3条回答
  • 2021-02-07 05:31

    Great thread. I was stuck on the same problem. To finish all that needs to be done you can:

    remove.packages(names(pkgNS[!pkgNS]))
    install.packages(names(pkgNS[!pkgNS]))
    
    0 讨论(0)
  • 2021-02-07 05:36

    Just run :

    update.packages(checkBuilt=TRUE)
    
    0 讨论(0)
  • 2021-02-07 05:50

    The function packageHasNamespace holds the key. Use it together with installed.packages:

    The following code loops through all of the library locations in .libPaths:

    pkgNS <- NULL
    for(i in seq_along(.libPaths())){
      libLoc <- .libPaths()[i]
      pkgs <- installed.packages(lib.loc=libLoc)[, 1]
      pkgNS <- c(pkgNS, 
          sapply(unname(pkgs), packageHasNamespace, package.lib=libLoc)
      )
    }
    

    The result of this code is a named logical vector pkgNS that is TRUE if the package has a namespace, FALSE if it doesn't.

    To get only those packages that don't have a namespace, create a subset of pkgNS where pkgNS is FALSE:

    pkgNS[!pkgNS]
    
          abind      bitops   CircStats    combinat     corpcor      deldir 
          FALSE       FALSE       FALSE       FALSE       FALSE       FALSE 
         Design         evd   financial         fpc      getopt      gsubfn 
          FALSE       FALSE       FALSE       FALSE       FALSE       FALSE 
           ineq       magic     mlbench    optparse     plotrix       ppcor 
          FALSE       FALSE       FALSE       FALSE       FALSE       FALSE 
    
    0 讨论(0)
提交回复
热议问题