prop_seen | R Documentation |
Calculate proportion of individuals seen for specific time
prop_seen(DT, category, ID_unique, time_seen)
DT |
Data.table with required data |
category |
Column that inculdes categories for which one wants to calculate the proportion seen (as.character) |
ID_unique |
Column that inculdes Unique ID by which one wants to calculte the days seen (as.character) |
time_seen |
Column that inculdes time seen (as.character) |
Data.table with category, time_step and proportion seen
dt = data.table(category = c(rep('M', 100), rep('F', 100)), ID_unique = as.character(c(1:200)), time_seen = sample(x = c(1:40), size = 200, replace = TRUE) ) ds = prop_seen(dt, 'category', 'ID_unique', 'time_seen') ## Not run: ggplot(data = ds, aes(x = time_step, y = prop_seen, col = category)) + scale_y_continuous(limits = c(0, 1)) + geom_line(size = 1.5) + scale_color_brewer(name = 'Category', palette = 'Dark2') + labs(x = 'Days seen', y = 'Proportion of individuals') + theme_classic(base_size = 24) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.