Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/71.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中的过滤表_R_Filter_Grouping - Fatal编程技术网

R中的过滤表

R中的过滤表,r,filter,grouping,R,Filter,Grouping,我想这样过滤我的表 输入表: x1 x2 x3 A B x A B y A B z C D u C D v x1 x2 x3 A B x,y,z C D u,v 输出表: x1 x2 x3 A B x A B y A B z C D u C D v x1 x2 x3 A

我想这样过滤我的表

输入表:

x1    x2    x3
A    B     x 
A    B     y
A    B     z
C    D     u
C    D     v
x1    x2    x3
A     B     x,y,z
C     D     u,v
输出表:

x1    x2    x3
A    B     x 
A    B     y
A    B     z
C    D     u
C    D     v
x1    x2    x3
A     B     x,y,z
C     D     u,v
可再现数据

df <- data.frame(
  x1 = c("A", "A", "A", "C", "C"), 
  x2 = c("B", "B", "B", "D", "D"), 
  x3 = c("x", "y", "z", "u", "v"),
  stringsAsFactors = FALSE
)

x3的预期结构是什么?您尝试过什么?如果您更喜欢列表列而不是字符串列,请将FUN参数更改为:FUN=functionx listx