我正在学习R并想知道lubridate是否应该从dplyr发出关于屏蔽"union"的消息.
在lubridate之前加载dplyr,我得到一个错误:arrange":
library(dplyr)
Attaching package: ‘dplyr’
The following objects are masked from ‘package:stats’:
filter, lag
The following objects are masked from ‘package:base’:
intersect, setdiff, setequal, union
library(lubridate)
df1 <- data.frame(c1 = "a", c2 = 1)
df2 <- data.frame(c1 = "a", c2 = 2)
union(df1, df2) %>% arrange(c1)
Error in UseMethod("arrange_") :
no applicable method for 'arrange_' applied to an object of class "list"
Run Code Online (Sandbox Code Playgroud)
似乎联合返回一个列表而不是一个data.frame,然后排列就会跳过它:
str(union(df1, df2))
List of 3
$ : Factor w/ 1 level "a": 1
$ : num …Run Code Online (Sandbox Code Playgroud) r ×1