I have information in a data.frame containing of two columns e.g.:
name age
a 10
b 20
c 30
and I have a list of names c b d
. Now I want to obtain a data.frame (or list or anything) of the attributes of the original data frame in the order of the list. For the above example, that would be
name age
c 30
b 20
d NA
I feel that this shouldn't be too difficult (even in-line maybe) but I can't find a way to do it in R.
Background:
I have a 'network' object created from an edge list. I have another of vertex-attributes, but no power over how each of these is ordered initially. Now I want assign the network vertices these attributes.
But in order to use
network %v% "age" <- dataframe[,2]
I'd need the data frame to be in the right order
and for
set.vertex.attribute(network, "age", hhs$age, v = hhs$di)
I'd need the vertex ids