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

as_long_data_frame() fails or has bad column names #297

Closed
richierocks opened this issue Sep 14, 2018 · 1 comment · Fixed by #748
Closed

as_long_data_frame() fails or has bad column names #297

richierocks opened this issue Sep 14, 2018 · 1 comment · Fixed by #748
Labels
bug an unexpected problem or unintended behavior

Comments

@richierocks
Copy link

Using some of the built-in graphs types, I see an error

library(igraph)
tetra <- make_graph("Tetrahedron")
as_long_data_frame(tetra)
#> Error in names(ver) <- paste0("from_", names(ver)): 'names' attribute [1] must be the same length as the vector [0]

ring <- make_ring(10)
as_long_data_frame(ring)
#> Error in names(ver) <- paste0("from_", names(ver)): 'names' attribute [1] must be the same length as the vector [0]

Making my own graph from graph_from_data_frame(), I see incorrect column names. The last two columns ought to be called from_name and to_name.

vertices <- data.frame(
  id = 1:10,
  name = letters[1:10]
)
edges <- data.frame(
  a = sample(10),
  b = sample(10),
  score = runif(10)
)
g <- graph_from_data_frame(edges, vertices = vertices)
as_long_data_frame(g)
#>    from to     score ver[el[, 1], ] ver2[el[, 2], ]
#> 1     4  5 0.2277997              d               e
#> 2     2  4 0.1393521              b               d
#> 3     1  8 0.4443383              a               h
#> 4     7  7 0.4660912              g               g
#> 5     9 10 0.9414583              i               j
#> 6     2  6 0.1375254              b               f
#> 7     8  9 0.5932517              h               i
#> 8     3  5 0.4985059              c               e
#> 9     1 10 0.5559388              a               j
#> 10    3  6 0.7224063              c               f
Copy link
Contributor

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.

@github-actions github-actions bot locked and limited conversation to collaborators Mar 31, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
2 participants