我有一个数据帧df,它由大量的行和几列组成。我想根据列x6中的内容删除一系列行(请参见下面的代码):
为此,我编写了代码:
subset(df, x6 == "1 -Energy", "2 - Industrial Processes and Product Use", "3
- Agriculture", "4 - Land Use, Land-Use Change and Forestry", "5 - Waste
management", "6 - Other Sector")
R不允许此命令,我想知道我需要更改什么?
感谢各种帮助。再次感谢!
Nordsee
答案 0 :(得分:1)
您可能会改用此命令:
subset(df, x6 %in% c("1 -Energy", "2 - Industrial Processes and Product Use", "3 - Agriculture", "4 - Land Use, Land-Use Change and Forestry", "5 - Waste management", "6 - Other Sector") )
当心%in%运算符。