根据另一个数据集中的值更改一个数据集中的值

时间:2016-04-27 13:50:00

标签: r conditional

我有以下问题:

names <- c("Peter", "Gabriel", "James", "Philip")
city <- c("LA", "NY","Chicago","Chicago")
number <- seq(1, length(names))

from <- c("Peter", "Peter", "Gabriel", "James", "James")
to <- c("James","Gabriel", "Philip", "Gabriel", "Philip")

nodes <- data.frame(names, city, number)
edges <- data.frame(from, to)

如何更改edges$from的值以匹配nodes$number中的值?

1 个答案:

答案 0 :(得分:0)

您可以使用以下内容

points = [-0.1325 -2.2267; -0.1525 -2.2267; -0.5319  1.0698; -1.3628 -0.1296;  1.7438  1.3784;  1.5770  0.9458;  0.5147 -2.6114;  0.8169 -2.2797; -1.0244  2.7143; -0.4422  2.8257; -1.7421 -2.4453; -2.4492 -0.4012]
linesegments = [-1.1258 -4.2270 -0.7196 -3.9662; -0.7196 -3.9662  0.4347 -0.4873; -2.3293  1.4275 -3.3717  2.2654; -2.3293  1.4275  0.4347 -0.4873;  1.3579  3.1700  3.3566  0.5079;  3.3566  0.5079  0.4347 -0.4873] % Each row is line with format [x1 y1 x2 y2];