Skip to contents

a simple “version”, or wrapper for packageDescription(), returning a named character vector, including "file", and still has a useful print() method.

Usage

pkgDesc (pkg, lib.loc = NULL, fields = NULL, onlyLT = 99, ...)
pkgBuilt(pkg, lib.loc = NULL, ...)

Arguments

pkg

a character string, name of an installed R package.

lib.loc

library location to find the package in; the default NULL uses the full .libPaths().

fields

a character vector (or NULL) specifying fields to be returned.

onlyLT

positive integer specifying an upper limit on the number of characters of fields to be returned and printed.

...

further optional arguments passed to packageDescription().

Value

a named character vector, with names, the fields, identical to the names of the list returned by packageDescription, plus its "file" attribute. Additionally the resulting vector is of class "Dlist" which activates a useful print() method.

Author

Martin Maechler, Jan. 2021

Note

The file is always returned; not the least that the author wants to see it quite often as his .libPaths() is non-trivial and typically longer than 4 entries.

I started to hate screen fulls of Authors and/or Description; when I wanted quite basic info, hence onlyLT with a reasonable default.

Examples

str(pd <- pkgDesc("sfsmisc"))
#>  'Dlist' Named chr [1:17] "sfsmisc" ...
#>  - attr(*, "names")= chr [1:17] "Package" "Title" "Version" "VersionNote" ...
pd[c("Date","Packaged", "Built","file")]
#> Date                    2026-08-03
#> NA                      NA
#> Built                   R 4.6.1; ; 2026-08-14 17:29:18 UTC; unix
#> file                    /tmp/RtmpNEWbPC/temp_libpathfa9262fdfa66/sfsmisc/Meta/package.rds

## see the effects of  `onlyLT` :
str(p1 <- pkgDesc("sfsmisc", onlyLT = Inf)) # .. [1:25] ..
#>  'Dlist' Named chr [1:21] "sfsmisc" ...
#>  - attr(*, "names")= chr [1:21] "Package" "Title" "Version" "VersionNote" ...
str(pD  <-pkgDesc("sfsmisc"              )) # .. [1:21] ..
#>  'Dlist' Named chr [1:17] "sfsmisc" ...
#>  - attr(*, "names")= chr [1:17] "Package" "Title" "Version" "VersionNote" ...
str(p50 <-pkgDesc("sfsmisc", onlyLT = 50 )) # .. [1:18] ..
#>  'Dlist' Named chr [1:14] "sfsmisc" "1.1-25" "2026-08-03" ...
#>  - attr(*, "names")= chr [1:14] "Package" "Version" "Date" "Maintainer" ...
t(sapply(list(full = p1, def. = pD, p50 = p50),
         function(pd) {n <- nchar(pd); c(summary(n)[-1], SUM = sum(n))}))
#>      1st Qu. Median  Mean 3rd Qu. Max.  SUM
#> full   10.00     40 201.3      73 1882 4228
#> def.   10.00     36  33.6      44   97  571
#> p50     7.75     21  25.1      40   65  351

pkgBuilt("sfsmisc")
#> Built                   R 4.6.1; ; 2026-08-14 17:29:18 UTC; unix
#> file                    /tmp/RtmpNEWbPC/temp_libpathfa9262fdfa66/sfsmisc/Meta/package.rds

## Show "Built" (and "file") for all packages whose namespaces are loaded:
lNs <- loadedNamespaces()
mlNs <- sapply(lNs, pkgBuilt)
t(mlNs) # typically prints nicely
#>              Built                                                        
#> gtable       "R 4.6.0; ; 2026-05-12 20:04:25 UTC; unix"                   
#> xfun         "R 4.6.1; x86_64-pc-linux-gnu; 2026-07-16 19:57:48 UTC; unix"
#> bslib        "R 4.6.1; ; 2026-08-14 13:47:16 UTC; unix"                   
#> ggplot2      "R 4.6.0; ; 2026-05-13 14:05:13 UTC; unix"                   
#> httr2        "R 4.6.1; ; 2026-07-16 21:15:35 UTC; unix"                   
#> htmlwidgets  "R 4.6.0; ; 2026-05-13 15:20:56 UTC; unix"                   
#> lattice      "R 4.6.1; x86_64-pc-linux-gnu; 2026-06-24 19:15:04 UTC; unix"
#> vctrs        "R 4.6.0; x86_64-pc-linux-gnu; 2026-05-12 20:03:45 UTC; unix"
#> tools        "R 4.6.1; x86_64-pc-linux-gnu; 2026-06-24 19:12:25 UTC; unix"
#> generics     "R 4.6.0; ; 2026-05-12 14:55:48 UTC; unix"                   
#> curl         "R 4.6.0; x86_64-pc-linux-gnu; 2026-05-04 12:21:31 UTC; unix"
#> tibble       "R 4.6.0; x86_64-pc-linux-gnu; 2026-05-13 14:12:25 UTC; unix"
#> proxy        "R 4.6.0; x86_64-pc-linux-gnu; 2026-05-12 14:56:00 UTC; unix"
#> fansi        "R 4.6.0; x86_64-pc-linux-gnu; 2026-05-12 15:05:02 UTC; unix"
#> lokern       "R 4.6.0; x86_64-pc-linux-gnu; 2026-04-24 21:42:28 UTC; unix"
#> cluster      "R 4.6.1; x86_64-pc-linux-gnu; 2026-06-24 19:18:09 UTC; unix"
#> pkgconfig    "R 4.6.0; ; 2026-05-12 15:02:40 UTC; unix"                   
#> methods      "R 4.6.1; x86_64-pc-linux-gnu; 2026-06-24 19:13:48 UTC; unix"
#> Matrix       "R 4.6.1; x86_64-pc-linux-gnu; 2026-06-24 19:15:11 UTC; unix"
#> data.table   "R 4.6.0; x86_64-pc-linux-gnu; 2026-05-12 15:06:10 UTC; unix"
#> checkmate    "R 4.6.0; x86_64-pc-linux-gnu; 2026-05-12 15:21:24 UTC; unix"
#> RColorBrewer "R 4.6.0; ; 2026-05-12 14:51:22 UTC; unix"                   
#> S7           "R 4.6.0; x86_64-pc-linux-gnu; 2026-05-12 15:02:23 UTC; unix"
#> desc         "R 4.6.0; ; 2026-05-12 19:13:37 UTC; unix"                   
#> lifecycle    "R 4.6.0; ; 2026-05-12 19:20:16 UTC; unix"                   
#> stringr      "R 4.6.0; ; 2026-05-13 14:00:14 UTC; unix"                   
#> compiler     "R 4.6.1; ; 2026-06-24 19:12:25 UTC; unix"                   
#> farver       "R 4.6.0; x86_64-pc-linux-gnu; 2026-05-12 14:59:48 UTC; unix"
#> textshaping  "R 4.6.0; x86_64-pc-linux-gnu; 2026-05-14 18:16:15 UTC; unix"
#> fontawesome  "R 4.6.0; ; 2026-05-13 13:43:42 UTC; unix"                   
#> htmltools    "R 4.6.0; x86_64-pc-linux-gnu; 2026-05-12 19:20:11 UTC; unix"
#> class        "R 4.6.1; x86_64-pc-linux-gnu; 2026-06-24 19:18:25 UTC; unix"
#> sass         "R 4.6.0; x86_64-pc-linux-gnu; 2026-05-13 13:41:47 UTC; unix"
#> gmp          "R 4.6.0; x86_64-pc-linux-gnu; 2026-04-24 02:31:51 UTC; unix"
#> yaml         "R 4.6.0; x86_64-pc-linux-gnu; 2026-05-12 15:06:04 UTC; unix"
#> htmlTable    "R 4.6.0; ; 2026-05-13 18:46:00 UTC; unix"                   
#> Formula      "R 4.6.1; ; 2026-08-14 13:39:12 UTC; unix"                   
#> pillar       "R 4.6.0; ; 2026-05-13 14:00:24 UTC; unix"                   
#> pkgdown      "R 4.6.1; ; 2026-07-16 21:27:12 UTC; unix"                   
#> jquerylib    "R 4.6.0; ; 2026-05-13 13:43:54 UTC; unix"                   
#> whisker      "R 4.6.0; ; 2026-05-12 15:00:23 UTC; unix"                   
#> MASS         "R 4.6.1; x86_64-pc-linux-gnu; 2026-06-24 19:14:59 UTC; unix"
#> cachem       "R 4.6.0; x86_64-pc-linux-gnu; 2026-05-12 19:18:47 UTC; unix"
#> Hmisc        "R 4.6.1; x86_64-pc-linux-gnu; 2026-06-30 20:28:16 UTC; unix"
#> rpart        "R 4.6.1; x86_64-pc-linux-gnu; 2026-06-24 19:18:21 UTC; unix"
#> tidyselect   "R 4.6.0; ; 2026-05-13 14:01:32 UTC; unix"                   
#> digest       "R 4.6.0; x86_64-pc-linux-gnu; 2026-05-12 15:18:55 UTC; unix"
#> stringi      "R 4.6.1; x86_64-pc-linux-gnu; 2026-08-14 13:40:01 UTC; unix"
#> dplyr        "R 4.6.0; x86_64-pc-linux-gnu; 2026-05-13 15:23:00 UTC; unix"
#> purrr        "R 4.6.0; x86_64-pc-linux-gnu; 2026-05-13 14:00:36 UTC; unix"
#> splines      "R 4.6.1; x86_64-pc-linux-gnu; 2026-06-24 19:14:07 UTC; unix"
#> fastmap      "R 4.6.0; x86_64-pc-linux-gnu; 2026-05-12 15:02:02 UTC; unix"
#> grid         "R 4.6.1; x86_64-pc-linux-gnu; 2026-06-24 19:14:00 UTC; unix"
#> colorspace   "R 4.6.1; x86_64-pc-linux-gnu; 2026-07-16 19:58:20 UTC; unix"
#> cli          "R 4.6.0; x86_64-pc-linux-gnu; 2026-05-12 14:52:06 UTC; unix"
#> magrittr     "R 4.6.0; x86_64-pc-linux-gnu; 2026-05-12 15:02:07 UTC; unix"
#> base64enc    "R 4.6.0; x86_64-pc-linux-gnu; 2026-05-12 15:16:29 UTC; unix"
#> grDevices    "R 4.6.1; x86_64-pc-linux-gnu; 2026-06-24 19:13:01 UTC; unix"
#> e1071        "R 4.6.0; x86_64-pc-linux-gnu; 2026-05-12 20:04:46 UTC; unix"
#> foreign      "R 4.6.1; x86_64-pc-linux-gnu; 2026-06-24 19:18:15 UTC; unix"
#> withr        "R 4.6.1; ; 2026-06-30 17:56:27 UTC; unix"                   
#> backports    "R 4.6.0; x86_64-pc-linux-gnu; 2026-05-12 15:03:07 UTC; unix"
#> utils        "R 4.6.1; x86_64-pc-linux-gnu; 2026-06-24 19:12:52 UTC; unix"
#> scales       "R 4.6.0; ; 2026-05-12 20:03:34 UTC; unix"                   
#> rmarkdown    "R 4.6.0; ; 2026-05-13 14:32:00 UTC; unix"                   
#> otel         "R 4.6.0; ; 2026-05-12 15:00:18 UTC; unix"                   
#> nnet         "R 4.6.1; x86_64-pc-linux-gnu; 2026-06-24 19:18:27 UTC; unix"
#> gridExtra    "R 4.6.1; ; 2026-06-30 19:13:35 UTC; unix"                   
#> datasets     "R 4.6.1; ; 2026-06-24 19:13:48 UTC; unix"                   
#> ragg         "R 4.6.0; x86_64-pc-linux-gnu; 2026-05-04 14:37:16 UTC; unix"
#> stats        "R 4.6.1; x86_64-pc-linux-gnu; 2026-06-24 19:13:17 UTC; unix"
#> graphics     "R 4.6.1; x86_64-pc-linux-gnu; 2026-06-24 19:13:08 UTC; unix"
#> memoise      "R 4.6.0; ; 2026-05-12 19:58:07 UTC; unix"                   
#> evaluate     "R 4.6.0; ; 2026-05-12 15:07:41 UTC; unix"                   
#> knitr        "R 4.6.0; ; 2026-05-12 20:03:03 UTC; unix"                   
#> rlang        "R 4.6.1; x86_64-pc-linux-gnu; 2026-07-16 19:57:55 UTC; unix"
#> downlit      "R 4.6.0; ; 2026-05-13 14:05:51 UTC; unix"                   
#> brand.yml    "R 4.6.0; ; 2026-04-24 22:28:14 UTC; unix"                   
#> glue         "R 4.6.0; x86_64-pc-linux-gnu; 2026-05-12 14:46:38 UTC; unix"
#> xml2         "R 4.6.1; x86_64-pc-linux-gnu; 2026-06-30 20:14:21 UTC; unix"
#> rstudioapi   "R 4.6.0; ; 2026-06-22 15:03:52 UTC; unix"                   
#> base         "R 4.6.1; ; 2026-06-24 19:14:11 UTC; unix"                   
#> jsonlite     "R 4.6.0; x86_64-pc-linux-gnu; 2026-05-12 15:06:51 UTC; unix"
#> R6           "R 4.6.0; ; 2026-05-12 15:18:48 UTC; unix"                   
#> systemfonts  "R 4.6.0; x86_64-pc-linux-gnu; 2026-05-14 18:13:38 UTC; unix"
#> fs           "R 4.6.0; x86_64-pc-linux-gnu; 2026-05-04 12:36:55 UTC; unix"
#> sfsmisc      "R 4.6.1; ; 2026-08-14 17:29:18 UTC; unix"                   
#>              file                                                               
#> gtable       "/tmp/.tmpwBKUcg/docs/library/gtable/Meta/package.rds"             
#> xfun         "/tmp/.tmpwBKUcg/docs/library/xfun/Meta/package.rds"               
#> bslib        "/tmp/.tmpwBKUcg/docs/library/bslib/Meta/package.rds"              
#> ggplot2      "/tmp/.tmpwBKUcg/docs/library/ggplot2/Meta/package.rds"            
#> httr2        "/tmp/.tmpwBKUcg/docs/library/httr2/Meta/package.rds"              
#> htmlwidgets  "/tmp/.tmpwBKUcg/docs/library/htmlwidgets/Meta/package.rds"        
#> lattice      "/opt/R/4.6.1/lib/R/library/lattice/Meta/package.rds"              
#> vctrs        "/tmp/.tmpwBKUcg/docs/library/vctrs/Meta/package.rds"              
#> tools        "/opt/R/4.6.1/lib/R/library/tools/Meta/package.rds"                
#> generics     "/tmp/.tmpwBKUcg/docs/library/generics/Meta/package.rds"           
#> curl         "/tmp/.tmpwBKUcg/docs/library/curl/Meta/package.rds"               
#> tibble       "/tmp/.tmpwBKUcg/docs/library/tibble/Meta/package.rds"             
#> proxy        "/tmp/.tmpwBKUcg/docs/library/proxy/Meta/package.rds"              
#> fansi        "/tmp/.tmpwBKUcg/docs/library/fansi/Meta/package.rds"              
#> lokern       "/tmp/.tmpwBKUcg/docs/library/lokern/Meta/package.rds"             
#> cluster      "/opt/R/4.6.1/lib/R/library/cluster/Meta/package.rds"              
#> pkgconfig    "/tmp/.tmpwBKUcg/docs/library/pkgconfig/Meta/package.rds"          
#> methods      "/opt/R/4.6.1/lib/R/library/methods/Meta/package.rds"              
#> Matrix       "/opt/R/4.6.1/lib/R/library/Matrix/Meta/package.rds"               
#> data.table   "/tmp/.tmpwBKUcg/docs/library/data.table/Meta/package.rds"         
#> checkmate    "/tmp/.tmpwBKUcg/docs/library/checkmate/Meta/package.rds"          
#> RColorBrewer "/tmp/.tmpwBKUcg/docs/library/RColorBrewer/Meta/package.rds"       
#> S7           "/tmp/.tmpwBKUcg/docs/library/S7/Meta/package.rds"                 
#> desc         "/tmp/.tmpwBKUcg/docs/library/desc/Meta/package.rds"               
#> lifecycle    "/tmp/.tmpwBKUcg/docs/library/lifecycle/Meta/package.rds"          
#> stringr      "/tmp/.tmpwBKUcg/docs/library/stringr/Meta/package.rds"            
#> compiler     "/opt/R/4.6.1/lib/R/library/compiler/Meta/package.rds"             
#> farver       "/tmp/.tmpwBKUcg/docs/library/farver/Meta/package.rds"             
#> textshaping  "/tmp/.tmpwBKUcg/docs/library/textshaping/Meta/package.rds"        
#> fontawesome  "/tmp/.tmpwBKUcg/docs/library/fontawesome/Meta/package.rds"        
#> htmltools    "/tmp/.tmpwBKUcg/docs/library/htmltools/Meta/package.rds"          
#> class        "/opt/R/4.6.1/lib/R/library/class/Meta/package.rds"                
#> sass         "/tmp/.tmpwBKUcg/docs/library/sass/Meta/package.rds"               
#> gmp          "/tmp/.tmpwBKUcg/docs/library/gmp/Meta/package.rds"                
#> yaml         "/tmp/.tmpwBKUcg/docs/library/yaml/Meta/package.rds"               
#> htmlTable    "/tmp/.tmpwBKUcg/docs/library/htmlTable/Meta/package.rds"          
#> Formula      "/tmp/.tmpwBKUcg/docs/library/Formula/Meta/package.rds"            
#> pillar       "/tmp/.tmpwBKUcg/docs/library/pillar/Meta/package.rds"             
#> pkgdown      "/tmp/.tmpwBKUcg/docs/library/pkgdown/Meta/package.rds"            
#> jquerylib    "/tmp/.tmpwBKUcg/docs/library/jquerylib/Meta/package.rds"          
#> whisker      "/tmp/.tmpwBKUcg/docs/library/whisker/Meta/package.rds"            
#> MASS         "/opt/R/4.6.1/lib/R/library/MASS/Meta/package.rds"                 
#> cachem       "/tmp/.tmpwBKUcg/docs/library/cachem/Meta/package.rds"             
#> Hmisc        "/tmp/.tmpwBKUcg/docs/library/Hmisc/Meta/package.rds"              
#> rpart        "/opt/R/4.6.1/lib/R/library/rpart/Meta/package.rds"                
#> tidyselect   "/tmp/.tmpwBKUcg/docs/library/tidyselect/Meta/package.rds"         
#> digest       "/tmp/.tmpwBKUcg/docs/library/digest/Meta/package.rds"             
#> stringi      "/tmp/.tmpwBKUcg/docs/library/stringi/Meta/package.rds"            
#> dplyr        "/tmp/.tmpwBKUcg/docs/library/dplyr/Meta/package.rds"              
#> purrr        "/tmp/.tmpwBKUcg/docs/library/purrr/Meta/package.rds"              
#> splines      "/opt/R/4.6.1/lib/R/library/splines/Meta/package.rds"              
#> fastmap      "/tmp/.tmpwBKUcg/docs/library/fastmap/Meta/package.rds"            
#> grid         "/opt/R/4.6.1/lib/R/library/grid/Meta/package.rds"                 
#> colorspace   "/tmp/.tmpwBKUcg/docs/library/colorspace/Meta/package.rds"         
#> cli          "/tmp/.tmpwBKUcg/docs/library/cli/Meta/package.rds"                
#> magrittr     "/tmp/.tmpwBKUcg/docs/library/magrittr/Meta/package.rds"           
#> base64enc    "/tmp/.tmpwBKUcg/docs/library/base64enc/Meta/package.rds"          
#> grDevices    "/opt/R/4.6.1/lib/R/library/grDevices/Meta/package.rds"            
#> e1071        "/tmp/.tmpwBKUcg/docs/library/e1071/Meta/package.rds"              
#> foreign      "/opt/R/4.6.1/lib/R/library/foreign/Meta/package.rds"              
#> withr        "/tmp/.tmpwBKUcg/docs/library/withr/Meta/package.rds"              
#> backports    "/tmp/.tmpwBKUcg/docs/library/backports/Meta/package.rds"          
#> utils        "/opt/R/4.6.1/lib/R/library/utils/Meta/package.rds"                
#> scales       "/tmp/.tmpwBKUcg/docs/library/scales/Meta/package.rds"             
#> rmarkdown    "/tmp/.tmpwBKUcg/docs/library/rmarkdown/Meta/package.rds"          
#> otel         "/tmp/.tmpwBKUcg/docs/library/otel/Meta/package.rds"               
#> nnet         "/opt/R/4.6.1/lib/R/library/nnet/Meta/package.rds"                 
#> gridExtra    "/tmp/.tmpwBKUcg/docs/library/gridExtra/Meta/package.rds"          
#> datasets     "/opt/R/4.6.1/lib/R/library/datasets/Meta/package.rds"             
#> ragg         "/tmp/.tmpwBKUcg/docs/library/ragg/Meta/package.rds"               
#> stats        "/opt/R/4.6.1/lib/R/library/stats/Meta/package.rds"                
#> graphics     "/opt/R/4.6.1/lib/R/library/graphics/Meta/package.rds"             
#> memoise      "/tmp/.tmpwBKUcg/docs/library/memoise/Meta/package.rds"            
#> evaluate     "/tmp/.tmpwBKUcg/docs/library/evaluate/Meta/package.rds"           
#> knitr        "/tmp/.tmpwBKUcg/docs/library/knitr/Meta/package.rds"              
#> rlang        "/tmp/.tmpwBKUcg/docs/library/rlang/Meta/package.rds"              
#> downlit      "/tmp/.tmpwBKUcg/docs/library/downlit/Meta/package.rds"            
#> brand.yml    "/tmp/.tmpwBKUcg/docs/library/brand.yml/Meta/package.rds"          
#> glue         "/tmp/.tmpwBKUcg/docs/library/glue/Meta/package.rds"               
#> xml2         "/tmp/.tmpwBKUcg/docs/library/xml2/Meta/package.rds"               
#> rstudioapi   "/tmp/.tmpwBKUcg/docs/library/rstudioapi/Meta/package.rds"         
#> base         "/opt/R/4.6.1/lib/R/library/base/Meta/package.rds"                 
#> jsonlite     "/tmp/.tmpwBKUcg/docs/library/jsonlite/Meta/package.rds"           
#> R6           "/tmp/.tmpwBKUcg/docs/library/R6/Meta/package.rds"                 
#> systemfonts  "/tmp/.tmpwBKUcg/docs/library/systemfonts/Meta/package.rds"        
#> fs           "/tmp/.tmpwBKUcg/docs/library/fs/Meta/package.rds"                 
#> sfsmisc      "/tmp/RtmpNEWbPC/temp_libpathfa9262fdfa66/sfsmisc/Meta/package.rds"

pkgs <- c("grid", "lattice", "MASS", "Matrix", "nlme", "lme4", "sfsmisc")
pkgs <- c("foobar", "barbar", pkgs, "kitty") # + names that typically don't exist
pkgsOk <- basename(find.package(pkgs, quiet=TRUE))
mpkg <- sapply(pkgsOk, pkgBuilt)
stopifnot(is.matrix(mpkg), nrow(mpkg) == 2)
t(mpkg["Built", , drop=FALSE]) # as 1-column matrix for readibility
#>         Built                                                        
#> grid    "R 4.6.1; x86_64-pc-linux-gnu; 2026-06-24 19:14:00 UTC; unix"
#> lattice "R 4.6.1; x86_64-pc-linux-gnu; 2026-06-24 19:15:04 UTC; unix"
#> MASS    "R 4.6.1; x86_64-pc-linux-gnu; 2026-06-24 19:14:59 UTC; unix"
#> Matrix  "R 4.6.1; x86_64-pc-linux-gnu; 2026-06-24 19:15:11 UTC; unix"
#> nlme    "R 4.6.1; x86_64-pc-linux-gnu; 2026-06-24 19:17:28 UTC; unix"
#> lme4    "R 4.6.1; x86_64-pc-linux-gnu; 2026-07-30 20:03:14 UTC; unix"
#> sfsmisc "R 4.6.1; ; 2026-08-14 17:29:18 UTC; unix"