Learn R Programming

scanstatistics (version 1.1.1)

df_to_matrix: Convert a long data frame to a wide matrix.

Description

Convert a long data frame to a wide matrix, with time along the row dimension and locations along the column dimension. Values in the matrix could be e.g. the observed counts or the population.

Usage

df_to_matrix(df, time_col = 1, location_col = 2, value_col = 3)

Value

A matrix with time on rows and locations on columns.

Arguments

df

A data frame with at least 3 columns.

time_col

Integer or string that specifies the time column.

location_col

Integer or string that specifies the location column.

value_col

Integer or string that specifies the value column.