timeShare: Built contact matrix based individual schedules of...

View source: R/timeShare.R

timeShareR Documentation

Built contact matrix based individual schedules of professionals.

Description

timeShare returns summaries the individual schedules of professionals at the ward scale to produce the contact matrix: average time spent in each ward (column) by professionals of each ward (row). The function considers that a professional is affiliated to the ward where he spend the most part of its activity. In case of equality, the order of rows is used to affiliate professionals to wards.

Usage

timeShare(contacts, namesincol1 = TRUE)

Arguments

contacts

data.frame. Contains the proportion of time spent by each professional (column) in each ward (rows).

namesincol1

logical. If TRUE, the first column of contacts must contain the ward ids. If FALSE, the ward ids are rownames of the contact data.table. Default is TRUE.

Value

data.frame

Examples

## Two wards: "a" and "b" with three professionals in "a" and two in "b"
ward_names <- letters[1:2]
pop_size_H <- c(3, 2)

contacts <- matrix(data = 0,
                   nrow = length(ward_names), ncol = sum(pop_size_H),
                   dimnames = list(ward_names,
                                   seq(sum(pop_size_H))))

## Individual schedules
contacts <- apply(contacts, 2, function(x){
# Random proportions
rp <- round(runif(1) * 100)
c(rp,100-rp)
})

contacts <- as.data.frame(contacts)

rownames(contacts) <- ward_names

timeShare(contacts, namesincol1 = FALSE)


MESuRS-Lab/mwss documentation built on Sept. 12, 2023, 12:08 a.m.