Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
b3b634a
Add metadata to the imported data
ThierryO Jan 8, 2025
d8834c4
🔖 Bump package version
ThierryO Jan 21, 2025
d4970ad
✨ Import only target species
ThierryO Jan 21, 2025
c9cb174
👷 Use checklist 0.4.1
ThierryO Jan 21, 2025
f48bd5e
♻️ Replace magritter pipe with base pipe
ThierryO Jan 30, 2025
4875045
♻️ Use everything() instead of across() without .cols
ThierryO Jan 30, 2025
9f352a4
♻️ Use quoted names instead of .data syntax in select()
ThierryO Jan 30, 2025
c442130
♻️ Prepare_analysis() stores a single bash script
ThierryO Jan 31, 2025
96840c6
♻️ Update retrieve_results() to changes in n2kanalysis v0.4.1
ThierryO Feb 4, 2025
1ba6ffa
♻️ Raed_relevant() handles base with either file or S3 bucket
ThierryO Feb 4, 2025
57a2884
🎨 Use tidyselect formatting
ThierryO Feb 13, 2025
6a66f7b
✨ Add descriptions on the result data files
ThierryO Feb 13, 2025
c49b009
🎨 Update script to run the entire analysis
ThierryO Feb 13, 2025
c02f04f
✨ Update results for the 2007-2024 report
ThierryO Mar 27, 2025
5bd173e
🐛 Fix read_relevant()
ThierryO Mar 27, 2025
9d2c5e8
update interactive report
ThierryO Mar 31, 2025
7db914b
💬 Update INBOmd pdf report
ThierryO Mar 31, 2025
dbd3cf9
🚨 Fix indentation linters
ThierryO Apr 1, 2025
3855ca6
🚨 Fix spelling issues
ThierryO Apr 1, 2025
aeb154c
👷 Use development version of checklist GHA
ThierryO Apr 1, 2025
51cfa01
➕ Add missing dependencies
ThierryO Apr 1, 2025
87e3247
📝 Update interactive report
ThierryO Apr 2, 2025
8835206
✨ Add files for Flemish Biodiversity Portal
ThierryO Apr 2, 2025
264f9e3
💚 Add missing alt text
ThierryO Apr 2, 2025
c955290
📝 Finalise report
ThierryO Apr 18, 2025
cd532c4
🐛 Fix textual trends by cycle
ThierryO Apr 23, 2025
b9c9e87
📝 Open links in VBP documents in a new tab
ThierryO Apr 25, 2025
b8afd7b
💚 Handle checklist issues
ThierryO Feb 6, 2026
a892a77
🐛 Handle species with too few observations
ThierryO Feb 13, 2026
f6a9527
✨ Update analysis script
ThierryO Feb 13, 2026
c533687
🐛 Make sure to add all analyses to the manifest
ThierryO Feb 18, 2026
a15975c
📝 Improve documentation of analysis script
ThierryO Feb 18, 2026
4baa383
✨ Create copy_manifest_objects
ThierryO Feb 20, 2026
aa36498
✨ Use quarto to generate pdf report
ThierryO Mar 13, 2026
c682376
✨ Update report for 2007-2025
ThierryO Apr 7, 2026
70b2c0b
✨ VBP output for 2007-2025
ThierryO Apr 7, 2026
73a8cb8
✨ Update result for 2007-2025
ThierryO Apr 7, 2026
ee70d2a
⚰️ Remove old version of the report
ThierryO Apr 7, 2026
d422c0d
🚨 Fix checklist issues
ThierryO Apr 8, 2026
a80f3b8
💚 Required version of n2kanalysis is available on r-universe
ThierryO Apr 9, 2026
321879f
📝 Add missing documentation
ThierryO Apr 9, 2026
cbb2481
💚 Add missing INLA repository
ThierryO Apr 9, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
.*\.log
.*\.tex
.*_files
\.Rproj\.user
\.quarto
^.*\.Rproj$
^CITATION\.cff$
^LICENSE.md$
Expand All @@ -20,10 +25,10 @@
^inst/*\.log$
^inst/*css$
^inst/*figure$
^inst/*rds$
^inst/intern_rapport$
^inst/output$
^inst/rapport$
^inst/results.rds$
^inst/website$
^man-roxygen$
^organisation.yml$
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/check_on_branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,3 @@ jobs:
contents: read
steps:
- uses: inbo/actions/check_pkg@main
with:
aptget: libpoppler-cpp-dev
2 changes: 1 addition & 1 deletion .github/workflows/check_on_different_r_os.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
extra-repositories: https://inbo.r-universe.dev
extra-repositories: https://inbo.r-universe.dev https://inla.r-inla-download.org/R/stable

- uses: r-lib/actions/setup-pandoc@v2

Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/check_on_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,3 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: inbo/actions/check_pkg@main
with:
aptget: libpoppler-cpp-dev
2 changes: 1 addition & 1 deletion .zenodo.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"title": "abvanalysis: Analysis of the Common Breeding Bird Survey",
"version": "0.2.4",
"version": "0.2.5",
"license": "GPL-3.0",
"upload_type": "software",
"description": "<p>Read in the raw data and prepare analysis datasets.<\/p>",
Expand Down
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ license: GPL-3.0
repository-code: https://github.com/inbo/abvanalysis/
type: software
abstract: "Read in the raw data and prepare analysis datasets."
version: 0.2.4
version: 0.2.5
16 changes: 10 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
Package: abvanalysis
Title: Analysis of the Common Breeding Bird Survey
Version: 0.2.4
Version: 0.2.5
Authors@R: c(
person("Thierry", "Onkelinx", , "thierry.onkelinx@inbo.be", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-8804-4216", affiliation = "Research Institute for Nature and Forest (INBO)")),
person("Research Institute for Nature and Forest (INBO)", , , "info@inbo.be", role = c("cph", "fnd"))
person("Research Institute for Nature and Forest (INBO)", , , "info@inbo.be", role = c("cph", "fnd"),
comment = c(ROR = "00j54wy13"))
)
Description: Read in the raw data and prepare analysis datasets.
License: GPL-3
URL: https://github.com/inbo/abvanalysis
BugReports: https://github.com/inbo/abvanalysis/issues
Depends:
R (>= 3.1.2)
R (>= 4.1.0)
Imports:
assertthat,
DBI,
Expand All @@ -25,17 +26,20 @@ Imports:
stringr,
tibble,
tidyr
Suggests:
Suggests:
DT,
effectclass,
gt,
INBOmd,
INBOtheme,
knitr,
pander,
plotly,
quarto,
rmarkdown,
scales,
tidyverse
VignetteBuilder:
VignetteBuilder:
knitr
Additional_repositories: https://inbo.r-universe.dev
Config/checklist/communities: inbo
Expand All @@ -44,4 +48,4 @@ Config/checklist/keywords: common breeding birds; monitoring; analysis;
Encoding: UTF-8
Language: en-GB
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.2
RoxygenNote: 7.3.3
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
### GNU GENERAL PUBLIC LICENSE
# GNU GENERAL PUBLIC LICENSE

Version 3, 29 June 2007

Expand Down
8 changes: 7 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Generated by roxygen2: do not edit by hand

export(copy_manifest_objects)
export(get_field_id)
export(get_linear_lincomb)
export(get_nonlinear_lincomb)
Expand Down Expand Up @@ -27,14 +28,14 @@ importFrom(assertthat,is.number)
importFrom(assertthat,is.string)
importFrom(assertthat,noNA)
importFrom(digest,sha1)
importFrom(dplyr,"%>%")
importFrom(dplyr,across)
importFrom(dplyr,anti_join)
importFrom(dplyr,arrange)
importFrom(dplyr,bind_cols)
importFrom(dplyr,bind_rows)
importFrom(dplyr,count)
importFrom(dplyr,distinct)
importFrom(dplyr,everything)
importFrom(dplyr,filter)
importFrom(dplyr,full_join)
importFrom(dplyr,group_by)
Expand All @@ -58,19 +59,24 @@ importFrom(git2rdata,push)
importFrom(git2rdata,read_vc)
importFrom(git2rdata,recent_commit)
importFrom(git2rdata,rm_data)
importFrom(git2rdata,update_metadata)
importFrom(git2rdata,verify_vc)
importFrom(git2rdata,write_vc)
importFrom(methods,slot)
importFrom(n2kanalysis,connect_inbo_s3)
importFrom(n2kanalysis,display)
importFrom(n2kanalysis,get_data)
importFrom(n2kanalysis,get_file_fingerprint)
importFrom(n2kanalysis,get_result)
importFrom(n2kanalysis,get_status_fingerprint)
importFrom(n2kanalysis,manifest_yaml_to_bash)
importFrom(n2kanalysis,n2k_composite)
importFrom(n2kanalysis,n2k_inla)
importFrom(n2kanalysis,n2k_manifest)
importFrom(n2kanalysis,read_manifest)
importFrom(n2kanalysis,read_model)
importFrom(n2kanalysis,status)
importFrom(n2kanalysis,store_manifest)
importFrom(n2kanalysis,store_manifest_yaml)
importFrom(n2kanalysis,store_model)
importFrom(purrr,map)
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# abvanalysis 0.2.5

* Import only the observations from the target species.
* Provided more metadata about the imported data.

# abvanalysis 0.2.4

* Update checklist machinery
Expand Down
44 changes: 44 additions & 0 deletions R/copy_manifest_objects.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#' Copy all object of the most recent manifest
#' @inheritParams n2kanalysis::store_model
#' @param target_folder Where to store the objects
#' @export
#' @importFrom dplyr filter
#' @importFrom n2kanalysis connect_inbo_s3 read_manifest read_model
#' store_manifest store_model
#' @importFrom rlang .data
copy_manifest_objects <- function(
base,
project,
target_folder = ".",
overwrite = FALSE
) {
manifest <- read_manifest(base = base, project = project)
store_manifest(manifest, base = target_folder, project = project)
manifest |>
slot("Manifest") |>
filter(is.na(.data$parent)) -> todo
file.path(target_folder, project) |>
list.files(recursive = TRUE) -> local_objects
if (overwrite) {
grepv("(converged|insufficient_data)", local_objects) -> local_objects
}
basename(local_objects) |>
gsub(pattern = "\\.rds$", replacement = "") -> done
for (hash in todo$fingerprint[!todo$fingerprint %in% done]) {
message(hash)
x <- try(read_model(hash, base = base, project = project))
while (inherits(x, "try-error")) {
browser()
connect_inbo_s3()
x <- try(read_model(hash, base = base, project = project))
}
store_model(
x,
base = target_folder,
project = project,
overwrite = overwrite
)
rm(x)
gc()
}
}
22 changes: 21 additions & 1 deletion R/get_field_id.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#' @param field_name The name of the field.
#' @export
#' @importFrom assertthat assert_that
#' @importFrom git2rdata read_vc write_vc
#' @importFrom git2rdata read_vc update_metadata write_vc
get_field_id <- function(repo, table_name, field_name) {
assert_that(
inherits(repo, "git_repository"), is.string(table_name),
Expand All @@ -19,6 +19,16 @@ get_field_id <- function(repo, table_name, field_name) {
file = "database_id", root = repo, sorting = c("table", "field"),
stage = TRUE
)
update_metadata(
file = "database_id", root = repo, stage = TRUE, name = "database_id",
title = "Database id for tables and fields",
description =
"This table describes to which table and field an id refers.",
field_description = c(
id = "Unique identifier", table = "Name of the table",
field = "Name of the field"
)
)
return(1L)
}

Expand All @@ -40,5 +50,15 @@ get_field_id <- function(repo, table_name, field_name) {
)
)
)
update_metadata(
file = "database_id", root = repo, stage = TRUE, name = "database_id",
title = "Database id for tables and fields",
description =
"This table describes to which table and field an id refers.",
field_description = c(
id = "Unique identifier", table = "Name of the table",
field = "Name of the field"
)
)
return(current_max + 1L)
}
30 changes: 15 additions & 15 deletions R/get_linear_lincomb.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#' @param formula the formula for the trend component
#' @export
#' @importFrom assertthat assert_that has_name is.string
#' @importFrom dplyr %>% across bind_cols bind_rows distinct group_by inner_join
#' mutate rename select summarise
#' @importFrom dplyr across bind_cols bind_rows distinct everything group_by
#' inner_join mutate rename select summarise
#' @importFrom rlang :=
#' @importFrom stats model.matrix
get_linear_lincomb <- function(
Expand All @@ -20,30 +20,30 @@ get_linear_lincomb <- function(
has_name(stratum_weights, "weight"), has_name(stratum_weights, stratum_var)
)

dataset %>%
select(c(stratum_var, time_var)) %>%
distinct() %>%
dataset |>
select(c(stratum_var, time_var)) |>
distinct() |>
inner_join(stratum_weights, by = stratum_var) -> all_weight
model.matrix(object = formula, all_weight) -> mm
(as.data.frame(mm) * all_weight$weight) %>%
mutate(ID = sprintf("linear_estimate_%02i", all_weight[[time_var]])) %>%
group_by(.data$ID) %>%
summarise(across(.fns = sum)) -> mm
stratum_weights %>%
(as.data.frame(mm) * all_weight$weight) |>
mutate(ID = sprintf("linear_estimate_%02i", all_weight[[time_var]])) |>
group_by(.data$ID) |>
summarise(across(.cols = everything(), .fns = sum)) -> mm
stratum_weights |>
mutate("{time_var}" := 1) -> trend_weight # nolint: object_name_linter.
mm_trend <- model.matrix(object = formula, trend_weight)
mm_trend <- as.data.frame(mm_trend) * trend_weight$weight
mm_trend[, -grep(":", colnames(mm_trend))] <- 0
if (has_name(mm_trend, "(Intercept)")) {
mm_trend$`(Intercept)` <- 0
}
mm_trend %>%
summarise(across(.fns = sum)) %>%
mutate(ID = "linear_trend") %>%
mm_trend |>
summarise(across(.cols = everything(), .fns = sum)) |>
mutate(ID = "linear_trend") |>
bind_rows(mm) -> weights
w_names <- weights$ID
weights %>%
select(-"ID") %>%
weights |>
select(-"ID") |>
as.list() -> weights
names(weights[[1]]) <- w_names
weights
Expand Down
Loading
Loading