#devtools::install_github("MiriamLL/sula")
library(sula)
<-(GPS_01) GPS01
Circadian classification
r
biologging
sula
Y2022
Create a column with the classification day or night
Intro
This post is to create a column day or night.
Data
For the exercises, test data is from masked boobies.
To access the data you have to install the package sula: devtools::install_github(“MiriamLL/sula”)
Transform time and date
library(dplyr)
Identify column with time date data
$dt <- as.POSIXct(strptime(GPS01$tStamp, "%Y-%m-%d %H:%M:%S")) GPS01
Extract hours
Once is in time and date format, you can extract just the hours
$hour <- as.numeric(substr(GPS01$dt, 12, 13)) GPS01
Classify day and night
Create a classification base on the time of sunset and sunrise.
<-GPS01 %>%
GPS01mutate(
day_night = case_when(
> 20 | hour < 6 ~ "night",
hour TRUE ~ "day"
))
Quantify proportions
library(tidyverse)
Now you can quantify how much your animals were out at night
%>%
GPS01 group_by(day_night)%>%
count()%>%
pivot_wider(names_from = day_night, values_from = n)
I hope this might help you
Further reads
Classify activities at night in penguins