Skip to contents

This is a helper function designed to make it easier to modify an already-defined data source. Generally, parameters passed here will replace existing entries in src if they exist, or will be added if not. The method and postprocess parameters are slightly different: see Details, below.

Usage

bb_modify_source(src, ...)

Arguments

src

data.frame or tibble: a single-row data source (as returned by bb_source)

...

: parameters as for bb_source

Value

as for bb_source: a tibble with columns as per the bb_source function arguments (excluding warn_empty_auth)

Details

With the exception of the method and postprocess parameters, any parameter provided here will entirely replace its equivalent in the src object. Pass a new value of NULL to remove an existing parameter.

The method and postprocess parameters are lists, and modification for these takes place at the list-element level: any element of the new list will replace its equivalent element in the list in src. If the src list does not contain that element, it will be added. To illustrate, say that we have created a data source with:

src <- bb_source(method=list("bb_handler_rget", parm1 = value1, parm2 = value2), ...)

Calling

bb_modify_source(src, method = list(parm1 = newvalue1))

will result in a new method value of list("bb_handler_rget", parm1 = newvalue1, parm2 = value2)

Modifying postprocess elements is similar. Note that it is not currently possible to entirely remove a postprocess component using this function. If you need to do so, you'll need to do it manually.

See also

Examples


## this pre-defined source requires a username and password
src <- bb_example_sources(
          "Sea Ice Trends and Climatologies from SMMR and SSM/I-SSMIS, Version 3")

## add username and password
src <- bb_modify_source(src,user="myusername",password="mypassword")

## or using the pipe operator
src <- bb_example_sources(
          "Sea Ice Trends and Climatologies from SMMR and SSM/I-SSMIS, Version 3") %>%
  bb_modify_source(user="myusername",password="mypassword")

## remove the existing "data_group" component
src %>% bb_modify_source(data_group=NULL)
#> # A tibble: 1 × 16
#>   id               name  description doc_url source_url citation license comment
#>   <chr>            <chr> <chr>       <chr>   <list>     <chr>    <chr>   <chr>  
#> 1 10.5067/IJ0T7HF… Sea … NSIDC prov… https:… <chr [1]>  Stroeve… Please… NA     
#> # ℹ 8 more variables: method <list>, postprocess <list>,
#> #   authentication_note <chr>, user <chr>, password <chr>,
#> #   access_function <chr>, data_group <chr>, collection_size <dbl>

## change just the 'level' setting of an existing method definition
src %>% bb_modify_source(method=list(level=3))
#> # A tibble: 1 × 16
#>   id               name  description doc_url source_url citation license comment
#>   <chr>            <chr> <chr>       <chr>   <list>     <chr>    <chr>   <chr>  
#> 1 10.5067/IJ0T7HF… Sea … NSIDC prov… https:… <chr [1]>  Stroeve… Please… NA     
#> # ℹ 8 more variables: method <list>, postprocess <list>,
#> #   authentication_note <chr>, user <chr>, password <chr>,
#> #   access_function <chr>, data_group <chr>, collection_size <dbl>

## remove the 'level' component of an existing method definition
src %>% bb_modify_source(method=list(level=NULL))
#> # A tibble: 1 × 16
#>   id               name  description doc_url source_url citation license comment
#>   <chr>            <chr> <chr>       <chr>   <list>     <chr>    <chr>   <chr>  
#> 1 10.5067/IJ0T7HF… Sea … NSIDC prov… https:… <chr [1]>  Stroeve… Please… NA     
#> # ℹ 8 more variables: method <list>, postprocess <list>,
#> #   authentication_note <chr>, user <chr>, password <chr>,
#> #   access_function <chr>, data_group <chr>, collection_size <dbl>