Reputation: 23
I tried to clean my data in R, my data looks like this
CustomerNumber Revenue
Customer1 3
Customer2 4
Customer3 5
How can I remove all the "Customer" in "Customer1" and make it like this
CustomerNumber Revenue
1 3
2 4
3 5
I tried to Google the answer, but can't find anything.
Upvotes: 0
Views: 28
Reputation: 388982
You could probably just replace the word "Customer" with an empty space using gsub
. Assuming df
as your data.frame
you can try,
df$CustomerName <- gsub("Customer", "", df$CustomerNumber)
df
# CustomerNumber Revenue
# 1 3
# 2 4
# 3 5
Upvotes: 1