Created
January 23, 2026 09:04
-
-
Save PietrH/45d9a4fb1b382980185ebc1ec3484df9 to your computer and use it in GitHub Desktop.
Example of etn with deprecated connection argument
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(etn) | |
| # Creating a connection object will result in a warning and not result in a | |
| # connection object | |
| my_con <- connect_to_etn() | |
| #> Warning: `connect_to_etn()` was deprecated in etn 2.3.0. | |
| #> ℹ You will be prompted for credentials instead. | |
| #> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was | |
| #> generated. | |
| class(my_con) | |
| #> [1] "NULL" | |
| get_animals(connection = my_con) | |
| #> Warning: The `connection` argument of `get_animals()` is deprecated as of etn v2.3.0. | |
| #> ℹ The connection argument is no longer used. You will be prompted for | |
| #> credentials instead. | |
| #> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was | |
| #> generated. | |
| #> # A tibble: 29,170 × 66 | |
| #> animal_id animal_project_code tag_serial_number tag_type tag_subtype | |
| #> <int> <chr> <chr> <chr> <chr> | |
| #> 1 5923 2004_Gudena 1208 acoustic animal | |
| #> 2 5924 2004_Gudena 1209 acoustic animal | |
| #> 3 5915 2004_Gudena 7416 acoustic animal | |
| #> 4 5916 2004_Gudena 7417 acoustic animal | |
| #> 5 5917 2004_Gudena 7418 acoustic animal | |
| #> 6 5918 2004_Gudena 7419 acoustic animal | |
| #> 7 5919 2004_Gudena 7420 acoustic animal | |
| #> 8 5920 2004_Gudena 7421 acoustic animal | |
| #> 9 5921 2004_Gudena 7422 acoustic animal | |
| #> 10 5922 2004_Gudena 7423 acoustic animal | |
| #> # ℹ 29,160 more rows | |
| #> # ℹ 61 more variables: acoustic_tag_id <chr>, | |
| #> # acoustic_tag_id_alternative <chr>, scientific_name <chr>, | |
| #> # common_name <chr>, aphia_id <int>, animal_label <chr>, | |
| #> # animal_nickname <chr>, tagger <chr>, capture_date_time <dttm>, | |
| #> # capture_location <chr>, capture_latitude <dbl>, capture_longitude <dbl>, | |
| #> # capture_method <chr>, capture_depth <chr>, … | |
| # Unnamed arguments will not work, because the first one will be assumed to be | |
| # connection | |
| get_animals(5923,"2004_Gudena") | |
| #> Warning: The `connection` argument of `get_animals()` is deprecated as of etn v2.3.0. | |
| #> ℹ The connection argument is no longer used. You will be prompted for | |
| #> credentials instead. | |
| #> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was | |
| #> generated. | |
| #> Error in `get_animals()`: | |
| #> ! Can't find animal_id `2004_Gudena` in: 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 28... | |
| #> Backtrace: | |
| #> ▆ | |
| #> 1. ├─evaluate::evaluate(...) | |
| #> 2. │ ├─base::withRestarts(...) | |
| #> 3. │ │ └─base (local) withRestartList(expr, restarts) | |
| #> 4. │ │ ├─base (local) withOneRestart(withRestartList(expr, restarts[-nr]), restarts[[nr]]) | |
| #> 5. │ │ │ └─base (local) doWithOneRestart(return(expr), restart) | |
| #> 6. │ │ └─base (local) withRestartList(expr, restarts[-nr]) | |
| #> 7. │ │ └─base (local) withOneRestart(expr, restarts[[1L]]) | |
| #> 8. │ │ └─base (local) doWithOneRestart(return(expr), restart) | |
| #> 9. │ ├─evaluate:::with_handlers(...) | |
| #> 10. │ │ ├─base::eval(call) | |
| #> 11. │ │ │ └─base::eval(call) | |
| #> 12. │ │ └─base::withCallingHandlers(...) | |
| #> 13. │ ├─base::withVisible(eval(expr, envir)) | |
| #> 14. │ └─base::eval(expr, envir) | |
| #> 15. │ └─base::eval(expr, envir) | |
| #> 16. │ └─etnservice::get_animals(...) | |
| #> 17. │ └─etnservice:::check_value(...) | |
| #> 18. │ └─assertthat::assert_that(...) | |
| #> 19. │ └─base::stop(assertError(attr(res, "msg"))) | |
| #> 20. └─evaluate (local) `<fn>`(`<assrtErr>`) | |
| #> 21. └─watcher$push(cnd) | |
| #> 22. └─handler$error(value) | |
| #> | |
| #> ℹ This is an error forwarded via the API. | |
| get_animals(animal_id = 5923, "2004_Gudena") | |
| #> Warning: The `connection` argument of `get_animals()` is deprecated as of etn v2.3.0. | |
| #> ℹ The connection argument is no longer used. You will be prompted for | |
| #> credentials instead. | |
| #> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was | |
| #> generated. | |
| #> # A tibble: 1 × 66 | |
| #> animal_id animal_project_code tag_serial_number tag_type tag_subtype | |
| #> <int> <chr> <chr> <chr> <chr> | |
| #> 1 5923 2004_Gudena 1208 acoustic animal | |
| #> # ℹ 61 more variables: acoustic_tag_id <chr>, | |
| #> # acoustic_tag_id_alternative <chr>, scientific_name <chr>, | |
| #> # common_name <chr>, aphia_id <int>, animal_label <chr>, | |
| #> # animal_nickname <chr>, tagger <chr>, capture_date_time <dttm>, | |
| #> # capture_location <chr>, capture_latitude <dbl>, capture_longitude <dbl>, | |
| #> # capture_method <chr>, capture_depth <chr>, | |
| #> # capture_temperature_change <chr>, release_date_time <dttm>, … | |
| # Named arguments will work | |
| get_animals(animal_id = 5923, animal_project_code = "2004_Gudena") | |
| #> # A tibble: 1 × 66 | |
| #> animal_id animal_project_code tag_serial_number tag_type tag_subtype | |
| #> <int> <chr> <chr> <chr> <chr> | |
| #> 1 5923 2004_Gudena 1208 acoustic animal | |
| #> # ℹ 61 more variables: acoustic_tag_id <chr>, | |
| #> # acoustic_tag_id_alternative <chr>, scientific_name <chr>, | |
| #> # common_name <chr>, aphia_id <int>, animal_label <chr>, | |
| #> # animal_nickname <chr>, tagger <chr>, capture_date_time <dttm>, | |
| #> # capture_location <chr>, capture_latitude <dbl>, capture_longitude <dbl>, | |
| #> # capture_method <chr>, capture_depth <chr>, | |
| #> # capture_temperature_change <chr>, release_date_time <dttm>, … | |
| # Running functions without arguments will work | |
| list_acoustic_project_codes() |> length() | |
| #> [1] 299 | |
| get_animals() | |
| #> # A tibble: 29,170 × 66 | |
| #> animal_id animal_project_code tag_serial_number tag_type tag_subtype | |
| #> <int> <chr> <chr> <chr> <chr> | |
| #> 1 5923 2004_Gudena 1208 acoustic animal | |
| #> 2 5924 2004_Gudena 1209 acoustic animal | |
| #> 3 5915 2004_Gudena 7416 acoustic animal | |
| #> 4 5916 2004_Gudena 7417 acoustic animal | |
| #> 5 5917 2004_Gudena 7418 acoustic animal | |
| #> 6 5918 2004_Gudena 7419 acoustic animal | |
| #> 7 5919 2004_Gudena 7420 acoustic animal | |
| #> 8 5920 2004_Gudena 7421 acoustic animal | |
| #> 9 5921 2004_Gudena 7422 acoustic animal | |
| #> 10 5922 2004_Gudena 7423 acoustic animal | |
| #> # ℹ 29,160 more rows | |
| #> # ℹ 61 more variables: acoustic_tag_id <chr>, | |
| #> # acoustic_tag_id_alternative <chr>, scientific_name <chr>, | |
| #> # common_name <chr>, aphia_id <int>, animal_label <chr>, | |
| #> # animal_nickname <chr>, tagger <chr>, capture_date_time <dttm>, | |
| #> # capture_location <chr>, capture_latitude <dbl>, capture_longitude <dbl>, | |
| #> # capture_method <chr>, capture_depth <chr>, … |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment