getHostData: Extracts specific data from a 'nosoiSim' object

Description Usage Arguments Value See Also Examples

View source: R/output_utilityFunctions.R

Description

This function extracts data user-defined data (i.e. table.hosts, N.infected, table.state or popStructure) from a nosoiSim object.

Usage

1
2
3
4
5
getHostData(
  nosoi.output,
  what = c("table.hosts", "N.infected", "table.state", "popStructure"),
  pop = "A"
)

Arguments

nosoi.output

an object of class nosoiSim

what

the data to get, among table.hosts, N.infected, table.state or popStructure.

pop

the population to be extracted (one of "A" or "B")

Value

Returns a data.table with the requested data.

See Also

To directly extract table.hosts or table.state, you can also use getTableHosts and getTableState respectively.

Examples

 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
t_incub_fct <- function(x){rnorm(x,mean = 5,sd=1)}
p_max_fct <- function(x){rbeta(x,shape1 = 5,shape2=2)}
p_Exit_fct  <- function(t){return(0.08)}

proba <- function(t,p_max,t_incub){
  if(t <= t_incub){p=0}
  if(t >= t_incub){p=p_max}
  return(p)
}

time_contact <- function(t){round(rnorm(1, 3, 1), 0)}

test.nosoi <- nosoiSim(type="single", popStructure="none",
                       length=40,
                       max.infected=100,
                       init.individuals=1,
                       nContact=time_contact,
                       param.nContact=NA,
                       pTrans = proba,
                       param.pTrans = list(p_max=p_max_fct,
                                           t_incub=t_incub_fct),
                       pExit=p_Exit_fct,
                       param.pExit=NA)


data.extracted <- getHostData(test.nosoi, "table.hosts", "A")

nosoi documentation built on Aug. 17, 2021, 5:09 p.m.