I need to check if values_saved_dice is a subset from x, for example
values_saved_dice <- c(2,2,2)
x <- c(6,3,2,2,5)
I tried the following function, expecting it should return FALSE.
all(is.element(value_saved_dices, x)
But it returns TRUE, when apparently it should be FALSE – because the number "2" appeared 3 times in value_saved_dices and x only has "2" twice.
Would appreciate any help, thanks!
>Solution :
We may paste the vector into string and use grepl to check if the substring is found or not
grepl(paste(values_saved_dice, collapse = ""), paste(x, collapse = ""))
[1] FALSE