Reputation: 480
Is there a way to remove numbers from strings in a column
ColA ColB
A.12 dff
B.34 dfa
C.545 dfd
Expected output
ColA ColB
A dff
B dfa
C dfd
Upvotes: 1
Views: 4025
Reputation: 389047
You can do this with gsub
in base R :
df$ColA <- gsub('[0-9.]', '', df$ColA)
df
# ColA ColB
#1 A dff
#2 B dfa
#3 C dfd
data
df <- structure(list(ColA = c("A.12", "B.34", "C.545"), ColB = c("dff",
"dfa", "dfd")), class = "data.frame", row.names = c(NA, -3L))
Upvotes: 6