get.matrix: Create regions - industries matrices from regular data frames

View source: R/get.matrix.r

get.matrixR Documentation

Create regions - industries matrices from regular data frames

Description

This function creates regions - industries (incidence) matrices from regular data frames (long to wide format) using the reshape2 package or the Matrix package

Usage

get.matrix (data)

Arguments

data

is a data frame with three columns (regions, industries, count)

sparse

Logical; shall the returned output be a sparse matrix? Defaults to FALSE, but can be set to TRUE if the dataset is very large

Author(s)

Pierre-Alexandre Balland p.balland@uu.nl

See Also

get.list

Examples

## generate a region - industry data frame
set.seed(31)
region <- c("R1", "R1", "R1", "R1", "R2", "R2", "R3", "R4", "R5", "R5")
industry <- c("I1", "I2", "I3", "I4", "I1", "I2", "I1", "I1", "I3", "I3")
data <- data.frame (region, industry)
data$count <- 1

## run the function
get.matrix (data)
get.matrix (data, sparse = TRUE)

PABalland/EconGeo documentation built on Jan. 5, 2023, 8:40 a.m.