timeShare | R Documentation |
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.
timeShare(contacts, namesincol1 = TRUE)
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. |
data.frame
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.