bcgov / bcgov/bccamtrap

Setting date ranges for rai_by_time() function (Solution)

Open
#33 0 comments 0 reactions 0 assignees View on GitHub
Solution
Dominant language
R
Stars
2
Forks
0
PR merge metrics
No merged PRs in 30d

Description

After calculating _rai_by_time_ and _elk_roll_avg_ on the full dataset, filter the dates:

#calculate RAI over a time window

rai_by_time(image_data)

#select a single species and calculate daily rolling values
#update species as required (i.e.: "__species_"__roll_avg_", species = _X_)

elk_roll_avg <- rai_by_time(
image_data,
by = "date",
species = "Roosevelt Elk",
roll = TRUE
)
elk_roll_avg

#create an specific data range subset
elk_roll_avg_subset <- filter(elk_roll_avg, between(date, as.Date("YYYY-MM-DD"), as.Date("YYYY-MM-DD")))

#visulaize rolling seven day RAI average by species using ggplots
#Update_ species as required (i.e.: "_species__"_roll_avg_", _title_)
#replace _elk_roll_avg_ with _elk_roll_avg_subset_ for date range specific

ggplot(elk_roll_avg, aes(x = date, y = roll_rai)) +
geom_line(colour = "red") +
theme_classic() +
labs(
title = "Rolling seven day average of Elk RAI",
x = "Date",
y = "7 day rolling average RAI"
)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.