當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


R dtplyr intersect.dtplyr_step 設置操作

這些是 dplyr 泛型 intersect()union()union_all()setdiff() 的方法。它們被翻譯為 data.table::fintersect()data.table::funion()data.table::fsetdiff()

用法

# S3 method for dtplyr_step
intersect(x, y, ...)

# S3 method for dtplyr_step
union(x, y, ...)

# S3 method for dtplyr_step
union_all(x, y, ...)

# S3 method for dtplyr_step
setdiff(x, y, ...)

參數

x, y

一對lazy_dt()

...

忽略

例子

dt1 <- lazy_dt(data.frame(x = 1:4))
dt2 <- lazy_dt(data.frame(x = c(2, 4, 6)))

intersect(dt1, dt2)
#> Source: local data table [2 x 1]
#> Call:   fintersect(`_DT18`, `_DT19`)
#> 
#>       x
#>   <int>
#> 1     2
#> 2     4
#> 
#> # Use as.data.table()/as.data.frame()/as_tibble() to access results
union(dt1, dt2)
#> Source: local data table [5 x 1]
#> Call:   funion(`_DT18`, `_DT19`)
#> 
#>       x
#>   <dbl>
#> 1     1
#> 2     2
#> 3     3
#> 4     4
#> 5     6
#> 
#> # Use as.data.table()/as.data.frame()/as_tibble() to access results
setdiff(dt1, dt2)
#> Source: local data table [2 x 1]
#> Call:   fsetdiff(`_DT18`, `_DT19`)
#> 
#>       x
#>   <int>
#> 1     1
#> 2     3
#> 
#> # Use as.data.table()/as.data.frame()/as_tibble() to access results

源代碼:R/step-set.R

相關用法


注:本文由純淨天空篩選整理自Hadley Wickham等大神的英文原創作品 Set operations。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。