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

Description Usage Arguments Author(s) See Also Examples

View source: R/get.matrix.r

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

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## 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 Nov. 13, 2020, 2:50 a.m.