我有一個名爲DF數據幀映射使用正則表達式的值:你怎麼R中
dput(df)
structure(list(Agent = structure(c(3L, 1L, 2L), .Label = c("[email protected]",
"[email protected]", "[email protected]"), class = "factor"),
Server = structure(c(3L, 1L, 2L), .Label = c("domain01",
"namesrv200", "proddb101"), class = "factor")), .Names = c("Agent",
"Server"), class = "data.frame", row.names = c(NA, -3L))
有一種叫做應用程序,包含值向量:
dput(app)
c("db", "dm", "ns")
我需要添加另一個列調用df調用應用程序,並將與代理列匹配的應用程序值插入到應用程序值中。下面是最終的結果DF1:
dput(df1)
structure(list(Agent = structure(c(3L, 1L, 2L), .Label = c("[email protected]",
"[email protected]", "[email protected]"), class = "factor"),
Server = structure(c(3L, 1L, 2L), .Label = c("domain01",
"namesrv200", "proddb101"), class = "factor"), App = structure(1:3, .Label = c("db",
"dm", "ns"), class = "factor")), .Names = c("Agent", "Server",
"App"), row.names = c(NA, -3L), class = "data.frame")
我怎麼能R中做到這一點,在DF創建一個列並插入值與應用價值相匹配代理列?
你真的沒有指定的匹配應該是怎樣發生的事情。 – joran
@joran,如果應用程序在df $代理中,將該應用程序值添加到df中的匹配行作爲新條目 – user1471980
我認爲您的示例數據也是錯誤的,'prodb101 @ webserver101'可能會顛倒過來。 –