prop_seen: Calculate proportion of individuals seen for specific time

View source: R/prop_seen.R

prop_seenR Documentation

Calculate proportion of individuals seen for specific time

Description

Calculate proportion of individuals seen for specific time

Usage

prop_seen(DT, category, ID_unique, time_seen)

Arguments

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)

Value

Data.table with category, time_step and proportion seen

Examples


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)

krietsch/auksRuak documentation built on Feb. 15, 2023, 2:44 p.m.