wants <- c("DescTools", "sets")
has <- wants %in% rownames(installed.packages())
if(any(!has)) install.packages(wants[!has])
a <- c(4, 5, 6)
b <- c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
m <- c(2, 1, 3, 2, 1)
n <- c(5, 3, 1, 3, 4, 4)
x <- c(1, 1, 2, 2)
y <- c(2, 1)
[1] TRUE
[1] FALSE TRUE TRUE FALSE TRUE FALSE TRUE
[1] 1 3 4
[1] 3
AllDuplicated()
from package DescTools
indicates all occurrences of a duplicated value, even the first one.
[1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[1] 2 1 3 5 4
[1] 1 3
[1] 2
[1] 5 4
[1] 2 5 4
[1] FALSE TRUE TRUE FALSE TRUE FALSE
[1] TRUE FALSE TRUE
[1] TRUE
[1] FALSE
[1] TRUE
sets
library(sets)
sa <- set(4, 5, 6)
sb <- set(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
sm <- set(2, 1, 3, 2, 1)
sn <- set(5, 3, 1, 3, 4, 4)
sx <- set(1, 1, 2, 2)
sy <- set(2, 1)
se <- 4
set_is_empty(sa)
[1] FALSE
[1] 2
{{}, {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, {1, 2, 3}}
{(4, 1), (4, 2), (5, 1), (5, 2), (6, 1), (6, 2)}
[1] TRUE
{1, 2, 3, 4, 5}
{1, 3}
{1, 2, 3, 7, 8, 9, 10}
{4, 5}
[1] TRUE
[1] TRUE
[1] TRUE
R markdown - markdown - R code - all posts