as.network.data.frame does not handle two-mode adjacency matrices correctly
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
Start by reproducing the two-mode example in the issue, then compare how as.network.data.frame and as.network.matrix interpret bipartite input. Trace the handling of bipartite and loops arguments in both entry points. Done means as.network.data.frame matches as.network.matrix without loop-related errors for the demonstrated input.
Written by the indexing model from the issue text.
Description
When called with a two-mode adjacency matrix, as.network.matrix will correctly interpret this as a graph with an enforced bipartition, with the passed matrix being the off-diagonal portion of the full adjacency matrix. as.network.data.frame will not, and indeed returns errors if e.g. the matrix is square and has non-zero diagonal entries when loops==FALSE. (See also related issue of as.network.data.frame not respecting the same semantics as as.network.matrix.) Setting loops=TRUE and bipartite=TRUE does not rectify the problem, because it throws an error when loops are set on bipartite graphs.
For this issue, the needed fix is for as.network.data.frame to correctly detect and implement two-mode matrix processing. Here is a demonstration:
#Create a two-mode adjacency structure
set.seed(1331)
g<-matrix(rbinom(25,1,0.2),5,5)
diag(g)<-1
#Coerce to a graph the traditional way
gn<-as.network.matrix(g,bipartite=T)
gn
gn[,]
#Now, with data frames.
gf<-as.data.frame(g)
gfn<-as.network(gf,bipartite=T) #Loop error!
gfn<-as.network(gf,bipartite=T,loops=T) #Displeased!
as.network.matrix(gf,bipartite=T) #Works fine!
We should be seeing the same behavior for as.network.data.frame as as.network.matrix here, and are not.
- 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
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
robjhyndman/forecast#1220 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
JamesHWade/deputy#192 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
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 · 1 reaction ·