I have a character vector:
A <- c("terrestrial human",
"animal 7 planet",
"geographic 23 locations",
"discovery kids")
I want to separate this into two vectors: one has all the entries containing digits, and the other containing data without any digits.
v1 <- c("animal 7 planet","geographic 23 locations")
v2 <- c("terrestrial human","discovery kids")
I took the liberty of declaring Matrix A
as a vector called A
instead, since it seems to be one dimensional -
A[!grepl(x = A, pattern = '[[:digit:]]')]
A[grepl(x = A, pattern = '[[:digit:]]')]