3 March 2023

Comparing two lists or vectors in R

I am always finding myself wanting to see the difference between two named lists or vectors.

Say you want to find parameters in list1 that are not in list2.

woops <- names(list1)[-which(names(list1) %in% names(list2))]

I didn't know that -which till today, hope it helps someone by sharing this.

Tags: R