Given the antibody_data data frame with entries for population group, calculates the number that are alive (alive to be infected, that is) for each time in times by population group

get_n_alive_group(antibody_data, times, demographics = NULL, melt_data = FALSE)

Arguments

antibody_data

the data frame of antibody data. See example_antibody_data

times

the vector of times to calculate number alive for

demographics

optional time-varying demographic data containing `individual`, `time`, and `population_group`

melt_data

if TRUE, returns a melted data frame. Returns a wide matrix otherwise.

Value

a matrix giving the number alive in each time point and population group, or a long data frame with `population_group`, `j`, and `n_alive` when `melt_data = TRUE`

See also

Other get_summary: get_DOBs(), get_n_alive()

Examples

data(example_antibody_data)
data(example_antigenic_map)
times <- unique(example_antigenic_map$inf_times)
get_n_alive_group(example_antibody_data, times)
#>      1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982
#> [1,]   25   26   26   27   27   29   31   31   31   31   32   32   36   37   37
#>      1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997
#> [1,]   38   38   38   38   38   40   40   40   41   43   44   45   45   45   46
#>      1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012
#> [1,]   47   47   47   48   48   48   49   50   50   50   50   50   50   50   50
#>      2013 2014 2015
#> [1,]   50   50   42