Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R:按列中的因子对dataframe中的行进行子集设置_R_Subset - Fatal编程技术网

R:按列中的因子对dataframe中的行进行子集设置

R:按列中的因子对dataframe中的行进行子集设置,r,subset,R,Subset,我有一个dataframe 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 Secto

我有一个dataframe 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

您可能指的是以下命令:

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%运算符。

如下:
子集(df,x6%in%c(“a”、“b”、“c”、“d”))