Skip to content

Commit

Permalink
simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
khufkens authored Sep 2, 2023
1 parent 9bcfd1b commit 5589696
Showing 1 changed file with 1 addition and 37 deletions.
38 changes: 1 addition & 37 deletions analysis/01_moonlight_glm_models_MDL.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,43 +9,7 @@ library(report)

#---- 0. read in data and subset ----

if(!file.exists("data/curated/data_MDL.rds")){

# read in data and subset the multi data logger
# select only night values
# drop those with missing lagged altitude values
# at the start of a day centered on midnight
# and not belonging to stationary periods (group = 0)
df <- readRDS("data/data_annotated.rds") |>
filter(
sensor == "MDL",
!is.na(lag_altitude),
stages == "night",
group != 0
)

# Scaling needs to happen to make sure
# that these are processed correctly between tags/species
# as the changes in flight height are tag/species specific
df <- df |>
group_by(tag) |>
mutate(
lag_altitude = as.vector(scale(lag_altitude))
) |>
select(
altbin,
moon_illuminance,
species,
lag_altitude,
tag
)

# save and compress for reproducibility
saveRDS(df, file = "data/curated/data_MDL.rds", compress = "xz")

} else {
df <- readRDS("data/curated/data_MDL.rds")
}
df <- readRDS("data/curated/data_MDL.rds")

#---- 1. fit model ----

Expand Down

0 comments on commit 5589696

Please sign in to comment.