matrix_to_predictions: Convert a contact matrix as output into a long-form tibble

View source: R/matrix_to_predictions.R

matrix_to_predictionsR Documentation

Convert a contact matrix as output into a long-form tibble

Description

This function is the opposite of predictions_to_matrix(). It converts a wide matrix into a long data frame. It is mostly used within plotting functions.

Usage

matrix_to_predictions(contact_matrix)

Arguments

contact_matrix

square matrix with age group to and from information in the row and column names.

Value

data.frame with columns age_group_to, age_group_from, and contacts.

Examples

fairfield <- abs_age_lga("Fairfield (C)")

# We can convert the predictions into a matrix

fairfield_school_contacts <- predict_contacts(
  model = polymod_setting_models$school,
  population = fairfield,
  age_breaks = c(0, 5, 10, 15, Inf)
)

fairfield_school_contacts

fairfield_school_mat <- predictions_to_matrix(fairfield_school_contacts)

fairfield_school_mat

matrix_to_predictions(fairfield_school_mat)

njtierney/conmat documentation built on April 17, 2025, 10:27 p.m.