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
| # Finding species that are only a single dataset and nowhere else: human | |
| # observations edition | |
| if(file.exists("query_results/0024071-251009101135966.zip")) { | |
| species_per_dataset <- | |
| readr::read_delim("query_results/0024071-251009101135966.zip") | |
| } else { | |
| species_per_dataset <- | |
| rgbif::occ_download_get("0024071-251009101135966") |> | |
| rgbif::occ_download_import() |
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
| # Passerines in South America | |
| # Data read from GBIF occurrence download (SQL QUERY) | |
| pas_sa <- | |
| rgbif::occ_download_get("0028483-251009101135966") |> | |
| rgbif::occ_download_import() |> | |
| dplyr::filter(!is.na(month)) | |
| # Identify the 3 most common genera ------------------------------------- | |
| common_genera <- pas_sa |> |
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
| # Get all rato data as a flat csv | |
| if(!rlang::is_installed("ratatouille", version = "1.0.4")){ | |
| pak::pak("inbo/ratatouille") | |
| } | |
| library(ratatouille) | |
| # To run this function you need to store your RATO database credentials as env variables, as RATO_USER and RATO_PWD, otherwise you'll get an error. | |
| all_rato_data <- ratatouille() |
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
| return_default <- function(my_param = 50){ | |
| rlang::eval_bare(formals(rlang::caller_fn(0))[["my_param"]]) | |
| } |
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
| object_name_message <- function(x){ | |
| cli::cli_inform("The object you passed is called {substitute(x)}") | |
| } | |
| object_name_message(letters) |
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
| repo <- "my_org/my_repo" | |
| zenodo_token <- "token from url in webhook page of repo" | |
| repo_response <- | |
| httr2::request("https://api.github.com/repos") %>% | |
| httr2::req_url_path_append(repo) %>% | |
| httr2::req_perform() %>% | |
| httr2::resp_body_json() | |
| release_response <- |
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
| ripple_shuffle <- function(object) { | |
| purrr::map( | |
| seq(1, length(object) / 2), | |
| ~ c( | |
| purrr::chuck(object, .x), | |
| purrr::chuck(object, length(object) - .x + 1) | |
| ) | |
| ) %>% | |
| unlist() | |
| } |
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
| get_inat_obs_radius <- function(taxon_id, lat, lng, radius) { | |
| api_response <- httr2::request( | |
| "https://api.inaturalist.org/v1/observations/" | |
| ) %>% | |
| httr2::req_url_query( | |
| taxon_id = taxon_id, | |
| lat = lat, | |
| lng = lng, | |
| radius = radius | |
| ) %>% |
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(dplyr) | |
| # Ensure ETN API-beta version | |
| remotes::install_github("inbo/[email protected]") | |
| library(etn) | |
| # Get number of detections, species and animals for lifewatch presentation | |
| project_codes_to_investigate <- c( | |
| "2010_PHD_REUBENS", | |
| "2011_RIVIERPRIK", | |
| "2012_LEOPOLDKANAAL", |
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
| # We are trying to find the closest allele per gene | |
| ## You could possibly do this with this package as well: | |
| ## https://bioconductor.org/packages/release/bioc/vignettes/GenomicRanges/inst/doc/GenomicRangesIntroduction.html#finding-the-nearest-genomic-position-in-granges-objects | |
| library(dplyr) # A Grammar of Data Manipulation | |
| library(assertthat) # Easy Pre and Post Assertions | |
| # Some example data |
NewerOlder