periodicity: Calculate periodicity metrics

Description Usage Arguments Details Value Examples

View source: R/periodicity.R

Description

This function takes in data for a recorder and calculates the periodicity metrics. All metrics are calculated within years.

Usage

1
2
3
4
5
6
7
periodicity(
  recorder_name,
  data,
  date_col = "date_start",
  recorder_col = "recorders",
  day_limit = 5
)

Arguments

recorder_name

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

data

the data.frame of recording information

date_col

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

recorder_col

the name of the column that contains the recorder names

day_limit

the threshold number of days a recorder must be active before these metrics are estimated. If the number of active days for the recorder is less than this number then the function will return NA values.

Details

In this function a streak is defined as a series of consecutive days on which a person made observations. A streak of 1 is a single days recording in isolation. 2 is 2 days back-to-back, 3 is 3 days in a row and so on.

Value

A data.frame with seven 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
## Not run: 

# load example data
head(cit_sci_data)

# run for one recorder
P <- periodicity(recorder_name = 3007,
                data = cit_sci_data,
                date_col = 'date',
                recorder_col = 'recorder',
                day_limit = 5)

# Run the metric for all recorders
P_all <- lapply(unique(cit_sci_data$recorder),
               FUN = periodicity,
               data = cit_sci_data,
               date_col = 'date',
               recorder_col = 'recorder',
               day_limit = 5)

# summarise as one table
P_all_sum <- do.call(rbind, P_all)

hist(P_all_sum$max_streak)

## End(Not run)

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