subset.SeroData: Creates a subset of a serological survey

View source: R/subset.R

subset.SeroDataR Documentation

Creates a subset of a serological survey

Description

This function creates a serological survey of the class SeroData.

Usage

## S3 method for class 'SeroData'
subset(data, sub = seq(1, data$N), loc = NULL, category = NULL)

Arguments

sub

Used in the subset function. A list of the indices of the individuals to be considered in the new SeroData object.

loc

Used in the subset function. A list of the location of the individuals to be considered in the new SeroData object.

sex

An optional character factor defining the sex of the individuals. It can be a single chain of characters or a vector of the same size as the number of sampled individuals. Default = NULL.

...

Additional arguments (not used).

Value

A list with the class SeroData, which contains the following items:

  • age: A vector of integers containing the age of the sampled individuals at the time of the latest sampling, of length N.

  • age_at_sampling: A vector of integers containing the age of the sampled individuals at the time of sampling, of length N.

  • Y: A vector of seropositivity status, of length N.

  • N: The number of individuals considered.

  • A: The maximal age.

  • NGroups: The total number of age groups.

  • sampling_year: A vector of sampling years, of length N.

  • location: A vector of the sampling location, of length N.

  • sex: A vector of the sex of each individual, of length N.

Author(s)

Nathanael Hoze nathanael.hoze@gmail.com

Examples


## A very simple example of a serological survey with three individuals: 
data = SeroData(age_at_sampling = c(10,32,24), Y=c(0,1,1), max_age = 50, age_cats = 1, sampling_year = 2017)

seroprevalence(data = data)
data2 = subset(data,c(1,3))

# add example with subset(data, location)


nathoze/Rsero documentation built on Dec. 1, 2024, 6:39 p.m.