as.network.data.frame does not follow as.network.matrix semantics
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 28/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- r
- Domain
- networking
Research direction
Start by comparing as.network.data.frame with as.network.matrix, including which.matrix.type and the handling of bipartite, loops, and matrix.type cues. Reproduce the two-mode, diagonal-with-loops==FALSE, and replicated-row cases; done means data-frame coercion follows matrix semantics wherever defined, with any remaining differences documented.
Written by the indexing model from the issue text.
Description
(This is related to, but not exactly the same as, the issue with two-mode adjacency processing with as.matrix.data.frame.)
When passed a matrix as input, network and as.network will use as.network.matrix to attempt to coerce the data into a network object. How to do this is complex, because there are many types of matrix representations of relational data, all of which are limited and/or leave ambiguities in what they represent. Thus, we use a combination of intelligent defaults and user-generated cues to figure out what behavior is desired. Among these is the use of which.matrix.type to guess whether an input matrix is a (1) standard adjacency matrix, (2) two-mode matrix, (3) incidence matrix, or (4) edge list, along with supplied prompts (e.g., the bipartite or loops attributes, or the matrix.type argument as.network.matrix, where given). We also follow some conventions on data handling, such as ignoring the diagonal of an adjacency matrix when loops==FALSE, which follows typical practice in the social network community (where diagonals are taken as undefined when loops are undefined, and anything might be stuck in those entries).
Currently, as.network.data.frame is not following all of the same semantics as as.network.matrix, which is problematic: wrapping a matrix in as.data.frame should not change the behavior of any network coercion function, in cases where the matrix version is well-defined. (It can extend matrix behavior, but never replace it.) This issue surfaced with the specific example of the above-cited two-mode issue, and I do not have an exhaustive list at this point. But here are examples that I see:
- As noted, two-mode adjacency matrices are not processed as two-mode adjacency matrices.
- Passing an adjacency structure with loops results in an error with
loops==FALSE, instead of ignoring diagonal entries. - Setting
loops=TRUEwith an adjacency structure having replicated rows leads to an error about multiple edges that seems to imply that the function is interpreting the matrix as if it were an edge list or transposed incidence matrix. (This even holds for rows that are all zero!)
There may be more. The needed fix is that as.network.data.frame must replicate the behavior of as.network.matrix where the former is well-defined, only extending it where a data.frame offers functionality that a matrix cannot supply - otherwise, one gets capricious changes in behavior based on e.g. how data is imported or stored (and, indeed, we are already seeing problems resulting from this). A second needed fix is that any differences need to be documented. (But there really should be many as noted above.)
- Dominant language
- R
- Stars
- 20
- Forks
- 7
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from statnet/network
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
-
Assigning a symmetric sociomatrix valued edges to an undriected network creates bidirectional edges. Openbug
Difficulty 3/5 1-2 days Newbie friendliness 45/100
Similar issues
-
bug triage_needed
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
pharmaverse/rtables#1123 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
Trying to reassign a reactiveVal to the name of an existing reactiveVal doesn't overwrite the latter Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100