Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
sit-design
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
UMR-ASTRE
sit-design
Commits
0ee5a661
Commit
0ee5a661
authored
3 years ago
by
Facundo Muñoz
Browse files
Options
Downloads
Patches
Plain Diff
Adopt "age" as a term for "days since release event".
parent
22ecc553
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/requirements.Rmd
+45
-37
45 additions, 37 deletions
src/requirements.Rmd
with
45 additions
and
37 deletions
src/requirements.Rmd
+
45
−
37
View file @
0ee5a661
...
...
@@ -1353,8 +1353,9 @@ Depending on the needs and hypotheses, the calculation could also aggregate days
# the package will have to perform. Only, using data extractors
# as mrr_surveys() et al.
## Days since release event for each surveyed population
surveys_days <-
## Days since release event (age) for each surveyed
## population of sterile males.
surveys_ages <-
cub_adult_data_raw |>
select(
survey = `Survey date`,
...
...
@@ -1367,9 +1368,29 @@ surveys_days <-
pivot_longer(
cols = yellow:pink,
names_to = "population",
values_to = "
day
"
values_to = "
age
"
) |>
filter(!is.na(day))
filter(!is.na(age))
captures_by_age <-
cub_adult_data_clean |>
inner_join(
## Implicitly filters sterile males
surveys_ages,
by = c("survey", "population")
) |>
select(-sex) |>
mutate(
species = factor(species),
population = factor(population)
) |>
## Keep observations up to the last age for which there is at least one
## observation of a sterile male.
group_by(age) |>
filter(sum(n) > 0) |>
ungroup()
## Use reported distances (based on rings) to the single
## release point
...
...
@@ -1378,32 +1399,19 @@ traps_distances <-
select(trap = `Trap Id`, d_m = `Distance (m)`) |>
unique()
## Mean dispersal distances by day and release
## Captures by trap, age and population
cub_dispersal_dat <-
cub_adult_data_clean |>
filter(
sex == "male",
# species == "aeg", # This is redundant with not wild next
population != "wild"
) |>
select(-species, -sex, -duration) |>
captures_by_age |>
left_join(
traps_distances,
by = "trap"
) |>
inner_join(
surveys_days,
by = c("survey", "population")
) |>
select(-survey) |>
select(-survey, -species, -duration) |>
mutate(
population = fct_inorder(population)
) |>
## Keep observations up to the last day for which there is at least one
## observation of a sterile male.
group_by(day) |>
filter(sum(n) > 0) |>
ungroup()
)
```
...
...
@@ -1412,12 +1420,12 @@ cub_dispersal_dat <-
## of MRR_template.xls.
cub_dispersal_dat |>
filter(
day
== 7, population == "pink") |>
filter(
age
== 7, population == "pink") |>
print(n = 21)
## MDD by
day
and population
## MDD by
age
and population
cub_dispersal_dat |>
group_by(
day
, population) |>
group_by(
age
, population) |>
## We have 21 surveys in each group (1 for each trap)
summarise(
mdd = ifelse(sum(n) > 0, sum(n * d_m)/sum(n), NA),
...
...
@@ -1429,7 +1437,7 @@ cub_dispersal_dat |>
)
## MDD by population, across
day
s.
## MDD by population, across
age
s.
cub_dispersal_dat |>
group_by(population) |>
## We have 21 surveys in each group (1 for each trap)
...
...
@@ -1438,15 +1446,15 @@ cub_dispersal_dat |>
.groups = "drop"
)
## MDD by
day
, across populations.
## MDD by
ages
, across populations.
cub_dispersal_dat |>
group_by(
day
) |>
group_by(
age
) |>
summarise(
mdd = sum(n * d_m)/sum(n),
.groups = "drop"
)
## MDD across
day
s and populations.
## MDD across
age
s and populations.
cub_dispersal_dat |>
summarise(
mdd = sum(n * d_m)/sum(n),
...
...
@@ -1457,15 +1465,15 @@ cub_dispersal_dat |>
Define a function `mrr_dispersal()` which computes the MDD estimates by
day
and population.
Define a function `mrr_dispersal()` which computes the MDD estimates by
age
and population.
Input:
```{r}
print_variable_table(
"x", "Either a `mrrsit` object or the outcome of a `adult_surveys()` call.",
"pool", "Character or NULL (default). Any of `populations`, `
day
s` or `all`.",
"by", "Character or NULL. Any of `populations`, `
day
s` or `all` (default). Alternative to `pool`.",
"pool", "Character or NULL (default). Any of `populations`, `
age
s` or `all`.",
"by", "Character or NULL. Any of `populations`, `
age
s` or `all` (default). Alternative to `pool`.",
header = FALSE
)
```
...
...
@@ -1479,7 +1487,7 @@ Only one of either the dual arguments `pool` or `by` should be implemented. I th
```{r}
cub_dispersal_dat |>
group_by(
day
, population) |>
group_by(
age
, population) |>
## We have 21 surveys in each group (1 for each trap)
summarise(
mdd = ifelse(sum(n) > 0, sum(n * d_m)/sum(n), NA),
...
...
@@ -1487,11 +1495,11 @@ Only one of either the dual arguments `pool` or `by` should be implemented. I th
)
```
For `by =
day
s` or `pool = populations` counts are pooled across populations and MDDs are computed by
day
s alone :
For `by =
age
s` or `pool = populations` counts are pooled across populations and MDDs are computed by
age
s alone :
```{r}
cub_dispersal_dat |>
group_by(
day
) |>
group_by(
age
) |>
## We have 21 surveys in each group (1 for each trap)
summarise(
mdd = ifelse(sum(n) > 0, sum(n * d_m)/sum(n), NA),
...
...
@@ -1499,7 +1507,7 @@ Only one of either the dual arguments `pool` or `by` should be implemented. I th
)
```
For `by = populations` or `pool =
day
s` counts are pooled across
day
s and MDDs are computed by populations alone :
For `by = populations` or `pool =
age
s` counts are pooled across
age
s and MDDs are computed by populations alone :
```{r}
cub_dispersal_dat |>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment