I tried to go about this myself and looked up online how to do this, but no direct answer. Basically, I am trying to delete the rows in a matrix that have more than 3 characters. My code is only deleting the last row. Rows 16-31 should be deleted. The i gets iterated, but only deletes the last column which satisfies the condition. However, more rows must be deleted. Thanks for the help in advance!
setwd("~/Desktop/Rpractice")
c <- c("1", "2", "3", "4", "5")
combine <- function (x, y) {combn (y, x, paste, collapse = ",")}
combination_mat <- as.matrix(unlist(lapply (1:length (c), combine, c)))
for (i in length(combination_mat)) {
if (nchar(combination_mat[i]) > 3) {
newmat <- print(as.matrix(combination_mat[-i,]))
}
}
