below is the lists. Is there way to remove elements that starts with asd
?
x1 <- list(asd1 = structure(19116, class = "Date"), asd2 = TRUE,
a3 = structure(19116, class = "Date"), MainNavBar = "V",
btnGetDWData = structure(0L, class = c("integer", "shinyActionButtonValue"
)), sd = "Info", fd = NULL,
fd = NULL)
CodePudding user response:
One way
x1[!grepl("^asd",names(x1))]
CodePudding user response:
Try this ,
x1[startsWith(names(x1) , "asd")] <- NULL
CodePudding user response:
x1[grep("^asd", names(x1))] <- NULL