clean_byname | R Documentation |
clean_value
Cleaning is performed when all entries in a row or column or both, depending on the value of margin
are within +/- tol
of clean_value
.
Internally, values are deemed within +/- of tol when
abs(x - clean_value) <= tol
.
clean_byname(a, margin = c(1, 2), clean_value = 0, tol = 0)
a |
the matrix to be cleaned |
margin |
the dimension over which cleaning should occur, |
clean_value |
the undesirable value. Default is |
tol |
the tolerance with which any value is deemed equal to When a row (when |
If there is concern about machine precision, you might want to call this function with
tol = .Machine$double.eps
.
a "cleaned" matrix, expunged of rows or columns that contain exclusively clean_value.
m <- matrix(c(-20, 1, -20, 2), nrow = 2, dimnames = list(c("r1", "r2"), c("c1", "c2"))) m m %>% clean_byname(margin = 1, clean_value = -20) # Eliminates -20, -20 row # Nothing cleaned, because no columns contain all 0's (the default clean_value). m %>% clean_byname(margin = 2) # Also works with lists list(m, m) %>% clean_byname(margin = 1, clean_value = -20) # Also works with data frames DF <- data.frame(m = I(list())) DF[[1,"m"]] <- m DF[[2,"m"]] <- m DF %>% clean_byname(margin = 1, clean_value = -20) m2 <- matrix(c(-20, -20, 0, -20, -20, 0, -20, -20, -20), nrow = 3, dimnames = list(c("r1", "r2", "r3"), c("c1", "c2", "c3")) ) m2 clean_byname(m2, margin = c(1,2), clean_value = -20) DF2 <- data.frame(m2 = I(list())) DF2[[1, "m2"]] <- m2 DF2[[2, "m2"]] <- m2 DF2 %>% clean_byname(margin = c(1, 2), clean_value = -20)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.