Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mixing matrix glitches #55

Closed
2 tasks
mbojan opened this issue Jan 23, 2021 · 1 comment
Closed
2 tasks

Mixing matrix glitches #55

mbojan opened this issue Jan 23, 2021 · 1 comment
Assignees

Comments

@mbojan
Copy link
Member

mbojan commented Jan 23, 2021

Following recent updates to network::mixingmatrix.network() the egodata method needs:

  • proper handling of NAs, e.g.:
d> data(emon)
d> mixingmatrix(emon$Texas, "Formalization")
      To
From   0.5   1   2   3   4 <NA> Sum
  0.5    0   6   3   1   1    1  12
  1      4  36  17  20   5    8  90
  2      2  14   3   5   1    5  30
  3      3  18   6   3   1    0  31
  4      1   7   2   2   0    1  13
  <NA>   1   3   4   2   0    0  10
  Sum   11  84  35  33   8   15 186
d> mixingmatrix(as.egodata(emon$Texas), "Formalization")
    0.5  1  2  3  4
0.5   0 10  5  4  2
1    10 72 31 38 12
2     5 31  6 11  3
3     4 38 11  6  3
4     2 12  3  3  0
Note:  Marginal totals can be misleading for undirected mixing matrices.
  • throw informative error if attrname is not in the data
d> mixingmatrix(as.egodata(emon$Texas), "no-such-attribute")
 Error in `[[<-.data.frame`(`*tmp*`, attrname, value = integer(0)) : 
  replacement has 0 rows, data has 25 
@krivit
Copy link
Member

krivit commented Jan 25, 2025

emon is directed, so this isn't the best example. However, the other issues are easily fixed.

@krivit krivit closed this as completed in 71c01ba Jan 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants