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

does as.sna.edgelist = TRUE argument to as.edgelist behave as intended? #71

Open
chad-klumb opened this issue Apr 18, 2022 · 0 comments

Comments

@chad-klumb
Copy link
Contributor

e.g.

require(network)
nw <- network.initialize(2, directed = FALSE)
nw[1,2] <- 1
as.matrix.network.edgelist(nw, as.sna.edgelist = FALSE)
as.matrix.network.edgelist(nw, as.sna.edgelist = TRUE)
as.edgelist(nw, as.sna.edgelist = FALSE)
as.edgelist(nw, as.sna.edgelist = TRUE)

produces

> as.matrix.network.edgelist(nw, as.sna.edgelist = FALSE)
     [,1] [,2]
[1,]    1    2
attr(,"n")
[1] 2
attr(,"vnames")
[1] 1 2
> as.matrix.network.edgelist(nw, as.sna.edgelist = TRUE)
     [,1] [,2] [,3]
[1,]    1    2    1
[2,]    2    1    1
attr(,"n")
[1] 2
attr(,"vnames")
[1] 1 2
> as.edgelist(nw, as.sna.edgelist = FALSE)
     [,1] [,2]
[1,]    1    2
attr(,"n")
[1] 2
attr(,"vnames")
[1] 1 2
attr(,"directed")
[1] FALSE
attr(,"bipartite")
[1] FALSE
attr(,"loops")
[1] FALSE
attr(,"class")
[1] "matrix_edgelist" "edgelist"        "matrix"          "array"          
> as.edgelist(nw, as.sna.edgelist = TRUE)
     [,1] [,2] [,3]
[1,]    1    2    1
attr(,"n")
[1] 2
attr(,"vnames")
[1] 1 2
attr(,"directed")
[1] FALSE
attr(,"bipartite")
[1] FALSE
attr(,"loops")
[1] FALSE
attr(,"class")
[1] "matrix_edgelist" "edgelist"        "matrix"          "array"          

i.e. the screening of edges in as.edgelist.matrix (which does not receive or recognize as.sna.edgelist in the current implementation) is dropping the "reversed" edge 2 1 from the output when as.sna.edgelist = TRUE is passed to as.edgelist, which seems like not what we want for sna (based on the behavior of as.matrix.network.edgelist).

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

1 participant