Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201894

Gather all the unique values from 2 columns into a new column

$
0
0

I have a dataframe which includes all the nodes' connections in a network and I want to create a new dataframe named 'nodes' with all the unique nodes. Im trying to do something like

eids<-as.factor(d$from)
mids<-as.factor(d$to)
nodes<-data.frame(c(eids,mids))
nodes<-unique(nodes)

but when I try to create the graph I get:Some vertex names in edge list are not listed in vertex data frame which means that part of my data is missed with this method. My dataset is quite large so I put a toy dataset here.

from<-c(2,3,4,3,1,2)
to<-c(8,8,7,5,6,5)
d<-data.frame(from,to)

Viewing all articles
Browse latest Browse all 201894

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>