I want to delete all the rows which has the character *.
When I try to delete * - it just deletes everything
("*" - how to avoid it from selecting everything?)
xx <- data.frame(
c1=c(".", ".", ".", ".", ".", "*", ".", ".", "."),
c2=c(".", ".", ".", ".", "Q", "Q", "R", ".", "."),
c3=c(".", ".", ".", ".", "W", "*", ".", ".", "."),
c4=c("A", "A", ".", ".", "I", ".", "P", ".", "."),
c5=c(".", ".", ".", ".", "D", "Q", "D", ".", "."),
c6=c(".", ".", ".", ".", "*", ".", ".", ".", "."),
c7=c(".", ".", ".", ".", "W", ".", ".", ".", "."),
row.names = paste0("r", 1:9)
)
xx[!grepl('*', xx),]
dplyr::filter(xx, !grepl('*', c1))
xx %>%
+ filter(!str_detect(xx, '*'))
The result should not have rows which has "*"
(delete row5 and row6 as they have *)
structure(list(c1 = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("-",
".", "*"), class = "factor"), c2 = structure(c(1L, 1L, 1L, 1L,
4L, 1L, 1L), .Label = c(".", "A", "Q", "R", "T"), class = "factor"),
c3 = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c(".",
"*", "S", "W"), class = "factor"), c4 = structure(c(2L, 2L,
1L, 1L, 4L, 1L, 1L), .Label = c(".", "A", "I", "P", "V"), class = "factor"),
c5 = structure(c(1L, 1L, 1L, 1L, 3L, 1L, 1L), .Label = c(".",
"A", "D", "K", "Q"), class = "factor"), c6 = structure(c(2L,
2L, 2L, 2L, 2L, 2L, 2L), .Label = c("-", ".", "*"), class = "factor"),
c7 = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("-",
".", "W"), class = "factor")), row.names = c("r1", "r2",
"r3", "r4", "r7", "r8", "r9"), class = "data.frame")
Thanks!