inbo/camtrapdp

Add assignment equivalent functions `deployments() <- value` , `media() <- value` and `observations() <- value`

PietrH opened this issue · 3 comments

Similar to purrr::pluck() <- : https://purrr.tidyverse.org/reference/pluck.html we would like to be able to create or modify objects nested within the datapackage structure.

Using the purrr syntax as an example:

https://github.com/tidyverse/purrr/blob/870696c7d9f3208298ea84a36d813ffd28e59e49/R/pluck.R#L103-L108

We probably want to make use of purrr::assign_in()

TODO

  • deployments(x) <-
  • media(x) <-
  • observations(x) <-
  • Update any reference in the code to x$data$name_of_df <- elsewhere in the code (e.g. here).

Scope

  • The assignment functions should only assign data.frames/tibbles
  • Do they need to be exported/public facing?
  • These assignment functions will provide in place assignment, and will modify the datapackage object they have as an argument
  • Similar to purrr::pluck() I suggest they return the modified object as well

For now, these functions can be internal.

Why update

x$data$observations <- dplyr::left_join(
?

It's better to use the function observations() <- dplyr::left_join() than setting the property x$data$observations directly (as it may move in the future).