How do I determine the author of an R package?

后端 未结 4 1406
迷失自我
迷失自我 2021-02-19 03:58

How can I determine who the authors of a package are? Given that we have this widely used code base, I think it is appropriate that I make a reference to the software I use in m

相关标签:
4条回答
  • 2021-02-19 04:25

    Some cleaning needed, but you get the idea. :)

    library(RCurl)
    gg <- getURL("http://cran.r-project.org/web/packages/ggdendro/index.html")
    gg <- readLines(textConnection(gg))
    gg[grep("Author:", gg)+1]
     [1] "<td>Andrie de Vries</td></tr>"
    

    Richie beat me to it, but here's a short way of extracting some information using citation.

    citation("ggdendro")$author
    [1] "Andrie de Vries <XXXXX@XXXXX.com>"
    

    In comments, Hadley suggested another method of reading straight from the DESCRIPTION file.

    > gg <- read.dcf(url("http://cran.r-project.org/web/packages/ggdendro/DESCRIPTION"))
    > gg[, "Maintainer"]
                               Maintainer 
    "Andrie de Vries <xxxxx@xxxxx.com>"
    
    0 讨论(0)
  • 2021-02-19 04:28

    As others have posted functions, and not explanations, I'll fill this in.

    Distributed with every package is a DESCRIPTION file. Optionally, a maintainer may include a CITATION file.

    The citation(pkgName) (where pkgName is a character string) function will look for the CITATION file first, then the DESCRIPTION file. If the former is found, it will present that file's contents. If the latter, it will auto-generate BibTeX output based on the fields in the DESCRIPTION file. This output may require some additional revision, so be careful before using the contents directly in a citation.

    In order to view the package description, packageDescription(pkgName) will do the trick. This will return a list of items, each based on a field from the DESCRIPTION file. This is your best bet if you want to programmatically work with those contents.

    One key issue is that the author(s) of a package and the maintainer(s) of the package may not be the same people. If you need assistance with a package, you should contact the maintainer(s). An example is nlme. First, a snippet from the citation info:

    > citation("nlme")
    
    To cite package 'nlme' in publications use:
    
      Jose Pinheiro, Douglas Bates, Saikat DebRoy, Deepayan Sarkar and the R Development Core Team (2011). nlme: Linear and
      Nonlinear Mixed Effects Models. R package version 3.1-102.
    

    And a snippet from the DESCRIPTION info:

    > packageDescription("nlme")
    Package: nlme
    Title: Linear and Nonlinear Mixed Effects Models
    Author: Jose Pinheiro (S version), Douglas Bates (up to 2007), Saikat DebRoy (up to 2002), Deepayan Sarkar (up to 2005), the
                  R Core team.
    Maintainer: R-core <R-core@R-project.org>
    

    Note that the authors listed participated over different intervals, but, should you want help today, you'd email R-core@R-project.org.

    Finally, as maintainers can create their own CITATION file, the CITATION info need not be a subset of the DESCRIPTION info. An example is from citation("base"), which includes, among other things, the ISBN record, which is not in the output of packageDescription("base").


    Update 1. If you'd like to show some love to authors or maintainers, here is some code get a list of the most frequently named authors or maintainers, based on the output of installed.packages(). (If you'd like to limit it to packages used by some code, then check out the mvbutils package and the foodweb function -- one could get crazy and further rank by the frequency of calls or time spent, if using Rprof.)

    Unfortunately, this code doesn't split strings into multiple names, so a collaboration is treated as 1 "person", possibly undercounting the work of individuals. If you want a careful analysis, you'll have to do a little more work. :)

    getMaint <- function(x){
        return(packageDescription(x)$Maintainer)
    }
    
    getAuth <- function(x){
        return(packageDescription(x)$Author)
    }
    
    nicePrint   <- function(x, N = 10){
        tmpTable    <- head(sort(table(x), decreasing = TRUE), N)
        tmpTable    <- as.data.frame(tmpTable)
        colnames(tmpTable) = "count"
        return(tmpTable)
    }
    
    vPkgs <- installed.packages()[,"Package"]
    
    listA   <- mapply(getAuth, vPkgs)
    listM   <- mapply(getMaint, vPkgs)
    
    nicePrint(listA)
    nicePrint(listM)
    

    Here's an example from one computer; apologies for the ugly obscured email addresses. The code above produces the correct email addresses from the DESCRIPTION file, but I've edited them out.

    Authors:

    nicePrint(listA)
                                                         count
    Diethelm Wuertz and many others, see the SOURCE file    14
    Hadley Wickham <xxxxxxxxxxxxxxxxxxx>                     7
    R Development Core Team and contributors worldwide       7
    Henrik Bengtsson <xxxxxxxxxxxxxxxxx>                     4
    Revolution Analytics                                     4
    Brian Ripley <xxxxxxxxxxxxxxxxxxxxx>.                    3
    David Scott <xxxxxxxxxxxxxxxxxxxxxx>                     3
    Luke Tierney <xxxxxxxxxxxxxxxxxxx>                       3
    R Development Core Team                                  3
    

    Maintainers:

    nicePrint(listM)
                                                     count
    Rmetrics Core Team <xxxxxxxxxxxxxxxxxxxxxxxxxxx>    19
    R Core Team <xxxxxxxxxxxxxxxxxxxx>                  13
    Brian Ripley <xxxxxxxxxxxxxxxxxxxxx>                 9
    Achim Zeileis <xxxxxxxxxxxxxxxxxxxxxxxxxxx>          7
    Hadley Wickham <xxxxxxxxxxxxxxxxxxx>                 7
    Torsten Hothorn <xxxxxxxxxxxxxxxxxxxxxxxxxxxxx>      7
    David Scott <xxxxxxxxxxxxxxxxxxxxxx>                 5
    Henrik Bengtsson <xxxxxxxxxxxxxxxxx>                 5
    Trevor Hastie <xxxxxxxxxxxxxxxxxxx>                  5
    Luke Tierney <xxxxxxxxxxxxxxxxxxx>                   4
    
    0 讨论(0)
  • 2021-02-19 04:34

    To be able to cite R or a package, use citation.

    citation()        #for base packages or R itself
    citation("nlme")
    
    0 讨论(0)
  • 2021-02-19 04:36

    use

    packageDescription("base")
    

    and read...

    0 讨论(0)
提交回复
热议问题