R Under development (unstable) (2024-10-14 r87233 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(qwraps2) > > set_a <- c("A", "a", "E", "I", "i", "O", "o", "U", "u", "E", "I") > set_b <- c("A", "a", "E", "e", "i", "o", "U", "u", "u", "a", "e") > set_c <- c("A", "e") > sd_ab <- set_diff(set_a, set_b) > sd_ba <- set_diff(set_b, set_a) > > stopifnot(!is.null(attr(sd_ab, "class"))) > stopifnot(!is.null(attr(sd_ba, "class"))) > stopifnot(!is.null(attr(sd_ab, "yname"))) > stopifnot(!is.null(attr(sd_ba, "yname"))) > stopifnot(!is.null(attr(sd_ab, "xname"))) > stopifnot(!is.null(attr(sd_ba, "xname"))) > > stopifnot(attr(sd_ab, "class") == "qwraps2_set_diff") > stopifnot(attr(sd_ba, "class") == "qwraps2_set_diff") > > stopifnot(attr(sd_ab, "xname") == "set_a") > stopifnot(attr(sd_ba, "xname") == "set_b") > > stopifnot(attr(sd_ab, "yname") == "set_b") > stopifnot(attr(sd_ba, "yname") == "set_a") > > stopifnot(names(sd_ab) == c("all_values", "x_only", "y_only", "both", "equal")) > stopifnot(names(sd_ba) == c("all_values", "x_only", "y_only", "both", "equal")) > > stopifnot(sort(sd_ab$all_values) == sort(sd_ba$all_values)) > stopifnot(sd_ab$x_only == sd_ba$y_only) > stopifnot(sd_ab$y_only == sd_ba$x_only) > stopifnot(sd_ab$both == sd_ba$both) > stopifnot(sd_ab$equal == sd_ba$equal) > stopifnot(set_diff(set_b, set_b)$equal) > > stopifnot(sd_ab$all_values == base::union(set_a, set_b)) > stopifnot(sd_ab$x_only == setdiff(set_a, set_b)) > stopifnot(sd_ab$y_only == setdiff(set_b, set_a)) > stopifnot(sd_ab$both == intersect(set_a, set_b)) > stopifnot(sd_ab$both == intersect(set_b, set_a)) > stopifnot(sd_ab$equal == setequal(set_a, set_b)) > stopifnot(sd_ab$equal == setequal(set_b, set_a)) > > > # verify the print method returns the original object > sd_ab_printed <- print(sd_ab) Total number of unique values: 10 Number of elements in both set_a and set_b: 7 Number of elements only in set_a: 2 unique elements: I, O Number of elements only in set_b: 1 unique elements: e > stopifnot(!is.null(sd_ab_printed)) > stopifnot(identical(sd_ab_printed, sd_ab)) > > proc.time() user system elapsed 0.26 0.10 0.35