Description Usage Arguments Value Examples
w_data
constructs spatial weights using dyadic
data recorded in a data frame. These weights may be symmetric or
asymmetric depending on user preference.
1 2 3 4 5 6 7 8 9 10 |
data |
A data frame containing dyadic flows |
id1 |
Variable identifying unit 1 |
id2 |
Variable identifying unit 2 |
flow1 |
Flows into unit 1 from unit 2 |
flow2 |
Flows into unit 2 from unit 1 |
flow |
Total flows between dyads. This will override |
missing_list |
For instances where the data contains dyads with no reported flows, the returned weights matrix will contain NAs. Setting this argument to TRUE returns a list of these observations |
quitetly |
Suppress warning messages |
A matrix consisting of weights derived from data
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | data(trade)
head(trade)
# Construct a symmetric dyadic matrix
w_symmetric <- w_data(data = trade, id1 = importer1, id2 = importer2,
flow = total_trade)
# Recode missing values to 0 if these correspond to cases with no flows:
w_symmetric[is.na(w_symmetric)] <- 0
# Verify symmetry:
isSymmetric(w_symmetric)
w_symmetric["Canada", "Mexico"]
w_symmetric["Mexico", "Canada"]
# Return list of dyads with no flows to explore whether these are missing data
w_missing <- w_data(data = trade, id1 = importer1, id2 = importer2,
flow = total_trade, missing_list = TRUE)
w_missing$France # Dyads not reporting trade with France
# Construct an asymmetric dyadic matrix
head(trade)
w_asymmetric <- w_data(data = trade, id1 = importer1, id2 = importer2,
flow1 = flow1, flow2 = flow2)
# Verify asymmetric
isSymmetric(w_asymmetric)
w_asymmetric["Canada", "Mexico"] # Imports of Canada from Mexico in current US millions $
w_asymmetric["Mexico", "Canada"] # Imports of Mexico from Canada in current US millions $
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.