activityRatio: Calculate activity ratio metrics

Description Usage Arguments Value Examples

View source: R/activityRatio.R

Description

This function takes in data for a recorder and calculates the activity ratio, total duration and number of active days

Usage

1
2
3
4
5
6
7
activityRatio(
  recorder_name,
  data,
  recorder_col = "recorders",
  date_col = "date_start",
  summer_days = NULL
)

Arguments

recorder_name

the name of the recorder for whom you want to calculate the metrics

data

the data.frame of recording information

recorder_col

the name of the column that contains the recorder names

date_col

the name of the column that contains the date. This must be formatted as a date

summer_days

Activity ratio is only calculated for the summmer period is this parameter is provided. This is a three column data.frame: year, Jday_start (numeric Julian day of the first day of summer), Jday_end (numeric Julian day of the last day of summer). These are returned as an attribute from summerData.

Value

A data.frame with four columns

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
## Not run: 

# load example data
head(cit_sci_data)

# Get the summer period
SD <- summerData(cit_sci_data, date_col = 'date')

ar <- activityRatio(recorder_name = 3007,
                    data = cit_sci_data,
                    recorder_col = 'recorder',
                    date_col = 'date',
                    summer_days = attr(SD, 'cutoffs'))
                    
# Run the metric for all recorders
ar_all <- lapply(unique(cit_sci_data$recorder),
                 FUN = activityRatio,
                 data = cit_sci_data,
                 recorder_col = 'recorder',
                 date_col = 'date',
                 summer_days = attr(SD, 'cutoffs'))

# summarise as one table
ar_all_sum <- do.call(rbind, ar_all)

hist(ar_all_sum$active_days, breaks = 80)

## End(Not run)

BiologicalRecordsCentre/recorderMetrics documentation built on Nov. 10, 2021, 2:03 p.m.