首页 > 解决方案 > 基于现有数据框的数据框中的子集行

问题描述

我希望代码在从另一个数据帧进行子集化后返回剩余的行。

Month = c('January','February','March','April','May','June')
Names = c("Jack", "Steve", "CJ", "Polar", "Ren", "Vent")
Color = c("Red", "Grey", "Yellow", "Blue", "Yellow", "Pink")
df= data.frame(Month, Names, Color)

Month = ""
Names = c("Jack", "Steve", "CJ", "Polar", "Ren", "Vent", "Keegan", "Fabian")
Color = c("Red", "Grey", "Yellow", "Blue", "Yellow", "Pink", "Pink", "Red")
df2 = data.frame(Month, Names, Color)

df$Month已填满,而df2$Month将是一个空列。基本上我想做的是dfdf2. 它应该还给我

    
Month   Names  Color
1       Keegan  Pink
2       Fabian  Red

标签: rdataframe

解决方案


推荐阅读