如何在两个数据帧中获得不匹配的数据帧?

时间:2015-07-13 15:48:01

标签: r

我有两个数据框:

DF1

ServerName
web01
web02
j2k101
tomcat101  
prdc1001

和df2

ServerName Application
Web01      Web
j2k10      Internal
tomcat101  Application

我想使用merge命令合并df1和df2以获取所有具有与之关联的Application的ServerNames

merge(df1,df2, by=c("ServerName")

我还想获得一个没有应用程序名称的服务器列表。我该怎么做?

1 个答案:

答案 0 :(得分:1)

df1[!(df1$ServerName %in% df2$ServerName),]

请注意,您的大小写不一致。如果你想要这个修复:

df1[!(toupper(df1$ServerName) %in% toupper(df2$ServerName)),]
相关问题