Skip to contents

Read lock files as tibble or list

Usage

read_lock(paths = "renv.lock", format = "list", encoding = "UTF-8")

Arguments

paths

Path to lock files

format

Return object format. Either 'list', 'tibble' or 'renv'. See details.

encoding

Text encoding, See jsonlite::fromJSON().

Value

A tibble or a list

Details

If argument paths is longer than one, then a list is returned. Argument format denotes return object format for the lockfile. Argument method denotes which method to use to read a lockfile. 'list' reads the lockfile and preserves it as it is as much as possible. 'tibble' returns a tibble.'renv' uses the read function from renv (renv::lockfile_read()) which returns a list. This option might update the lockfile structure to be current.

Examples

# read one lock file as a tibble
path <- file.path(system.file("extdata", package = "renvtools"), "renv-r4.4.1.lock")
read_lock(path, format = "tibble")
#> R version: 4.4.1 
#> Bioc version: 3.19 
#> # A tibble: 294 x 14
#>    Package     Version  Source  Repository Hash  Requirements OS_type RemoteType
#>    <chr>       <chr>    <chr>   <chr>      <chr> <list>       <chr>   <chr>     
#>  1 BH          1.84.0-0 Reposi~ RSPM       a823~ <NULL>       NA      NA        
#>  2 BiocManager 1.30.23  Reposi~ RSPM       47e9~ <chr [1]>    NA      NA        
#>  3 BiocVersion 3.19.1   Biocon~ Bioconduc~ b892~ <chr [1]>    NA      NA        
#>  4 CFtime      1.4.0    Reposi~ RSPM       630f~ <chr [2]>    NA      NA        
#>  5 DBI         1.2.3    Reposi~ RSPM       065a~ <chr [2]>    NA      NA        
#>  6 DiagrammeR  1.0.11   Reposi~ RSPM       584c~ <chr [19]>   NA      NA        
#>  7 FNN         1.1.4    Reposi~ RSPM       eaab~ <chr [1]>    NA      NA        
#>  8 KernSmooth  2.23-24  Reposi~ CRAN       9f33~ <chr [2]>    NA      NA        
#>  9 Lahman      11.0-0   Reposi~ RSPM       5b6f~ <chr [2]>    NA      NA        
#> 10 LearnBayes  2.15.1   Reposi~ RSPM       b2dd~ <NULL>       NA      NA        
#> # i 284 more rows
#> # i 6 more variables: RemoteHost <chr>, RemoteRepo <chr>, RemoteUsername <chr>,
#> #   RemotePkgRef <chr>, RemoteRef <chr>, RemoteSha <chr>

# read one lock file as a list
x <- read_lock(path, format = "list")

# read several lock files as a list of tibbles
paths <- list.files(system.file("extdata", package = "renvtools"), full.names = TRUE)
names(paths) <- basename(paths)
x <- read_lock(paths, format = "tibble")

# read several lock files as a list of lists
x <- read_lock(paths, format = "list")