Pergunta

I try to make an igraph from dataframe columns called routes$Source Airport and routes$Destination Airport I type in

g<-graph.formula("routes$Source Airport","routes$Destination Airport")
plot.igraph(g)

I'm not sure that is correct!!!

Foi útil?

Solução

It's a bad idea to have spaces in the names of your variables. Let's just use source and dest instead for our variable names:

dat <- data.frame(source=1:3, dest=c(3, 1, 1))

You can make and plot your graph with the graph.data.frame function:

g <- graph.data.frame(dat)
plot(g)

graph

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top