Skip to contents

Usespurrr::modify_at to apply a set of methods at specific locations in a list.

Usage

prep_for_json(x, prep_methods_list = prep_methods())

Arguments

x

list. Named list of data frames, lists, or vectors. For methods to be applied, the names of the list items should match the names in the methods list

prep_methods_list

list. Named list of methods where each items is a function to applied to corresponding items in x.

Value

Named list where methods have been applied.

Examples


wddsWizard::becker_project_metadata |>
   prep_for_json()
#> $creators
#> $creators[[1]]
#> Warning: Setting row names on a tibble is deprecated.
#> # A tibble: 1 × 5
#>   name             givenName familyName affiliation      nameIdentifiers 
#> * <chr>            <chr>     <chr>      <list>           <list>          
#> 1 Daniel J. Becker Daniel J. Becker     <tibble [1 × 2]> <tibble [1 × 2]>
#> 
#> $creators[[2]]
#> Warning: Setting row names on a tibble is deprecated.
#> # A tibble: 1 × 4
#>   name            givenName   familyName affiliation     
#> * <chr>           <chr>       <chr>      <list>          
#> 1 Guang-Sheng Lei Guang-Sheng Lei        <tibble [1 × 2]>
#> 
#> 
#> $descriptions
#> $descriptions[[1]]
#> Warning: Setting row names on a tibble is deprecated.
#> # A tibble: 1 × 2
#>   description                                             descriptionType
#> * <chr>                                                   <chr>          
#> 1 Bats can harbor many pathogens without showing disease… Abstract       
#> 
#> 
#> $fundingReferences
#> $fundingReferences[[1]]
#> Warning: Setting row names on a tibble is deprecated.
#> # A tibble: 1 × 3
#>   funderName                  funderIdentifier                     awardNumber  
#> * <chr>                       <chr>                                <chr>        
#> 1 National Geographic Society http://dx.doi.org/10.13039/100006733 NGS-55503R-19
#> 
#> $fundingReferences[[2]]
#> Warning: Setting row names on a tibble is deprecated.
#> # A tibble: 1 × 2
#>   funderName         funderIdentifier                    
#> * <chr>              <chr>                               
#> 1 Indiana University http://dx.doi.org/10.13039/100006733
#> 
#> $fundingReferences[[3]]
#> Warning: Setting row names on a tibble is deprecated.
#> # A tibble: 1 × 2
#>   funderName            funderIdentifier                    
#> * <chr>                 <chr>                               
#> 1 College of Charleston http://dx.doi.org/10.13039/100009789
#> 
#> 
#> $identifiers
#> $identifiers[[1]]
#> Warning: Setting row names on a tibble is deprecated.
#> # A tibble: 1 × 1
#>   identifier                                            
#> * <chr>                                                 
#> 1 https://www.ebi.ac.uk/pride/archive/projects/PXD031075
#> 
#> 
#> $language
#> [x] "en"
#> 
#> $methodology
#> $methodology$eventBased
#> [x] false
#> 
#> $methodology$archival
#> [x] false
#> 
#> 
#> $publicationYear
#> [x] "2022"
#> 
#> $rights
#> $rights[[1]]
#> Warning: Setting row names on a tibble is deprecated.
#> # A tibble: 1 × 1
#>   rights
#> * <chr> 
#> 1 CC0   
#> 
#> 
#> $subjects
#> $subjects[[1]]
#> Warning: Setting row names on a tibble is deprecated.
#> # A tibble: 1 × 1
#>   subject   
#> * <chr>     
#> 1 Proteomics
#> 
#> $subjects[[2]]
#> Warning: Setting row names on a tibble is deprecated.
#> # A tibble: 1 × 1
#>   subject        
#> * <chr>          
#> 1 Immune Response
#> 
#> 
#> $titles
#> # A tibble: 1 × 1
#>   title                                                                       
#>   <chr>                                                                       
#> 1 Serum proteomics of coronavirus shedding in vampire bats (Desmodus rotundus)
#> 

 a <- list("hello_world" = 1:10 )
 methods_list <- list("hello_world" = function(x){x*2},
                       "unused_method" = function(x){x/2})
 prep_for_json(a,methods_list)
#> $hello_world
#>  [1]  2  4  6  8 10 12 14 16 18 20
#>