Skip to content

Setting date ranges for rai_by_time() function (Solution) #33

@btitaro

Description

@btitaro

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"
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    SolutionA solution to a common problem

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions