Description Usage Arguments Value Examples
View source: R/activityRatio.R
This function takes in data for a recorder and calculates the activity ratio, total duration and number of active days
1 2 3 4 5 6 7 | activityRatio(
recorder_name,
data,
recorder_col = "recorders",
date_col = "date_start",
summer_days = NULL
)
|
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 |
A data.frame with four columns
recorder
- The name of the recorder, as given in the recorder_name argument
activity_ratio
- The proportion of days on which the volunteer was active in relation to the total days he/she remained linked to the project (i.e. active_days
/ duration
. Duration is either the number of days elapsed from their first to last record, or if summer_days
is provided it is the the number of days elapsed from their first to last record that fall into the summer periods)
total_duration
- The total number of days the volunteer was involved in the project, calculated as the number of days from the first record they submitted to the last (inclusive)
active_days
- The total number of unique dates on which observations were made
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.