Load packages library(tidyverse) Problem statement Assume we have some vectors (eg, 3), and we want to check if they are equal (the same elements in each vector). Assume further we do not in advance the number of vectors to check.
Here’s some toy data.
a<- c(1,2,3,4) b<- c(1,2,3,5) c<- c(1,3,4,5) The gist This soluation is based on the code of Akrun from this SO post (slightly adapted).
sum(reduce(map2(list(a,b,c), list(a), ==
), &
)) #> [1] 1 Explanation Let’s break that in handy pieces to get a grip on …