#' Check two lists are equal, up to order of elements
#'
#' @param l1 first list
#' @param l2 second list
#' @author Andrew Pfeiffer <andrew.j.pfeiffer@@gmail.com>
#' @export
#' @note 22 June 2017
setdiff_list <- function(l1, l2){
# Check that they're lists
if (!(identical(class(l1), "list") & identical(class(l2), "list")))
stop("Arguments must be lists")
# Get names in actual list that are different to those in expected list
names_diff <- sapply(names(l1), function(x) !identical(l1[[x]], l2[[x]]))
# Output list
l1[names_diff]
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.