0

I have a question with regards too; how do I replace numbers like, 1,2,300,400,5000,6000, etc... into a word, for example, 'numbertag'.

The data consists of tweets related to cryptocurrency.

For example;

Text tweet:

"bitcoin smashes through $5000usd barrier, pending bitcoingold fork.

With the code, the tweet has to be;

"bitcoin smashes through $numbertagusd barrier, pending bitcoingold fork.

Best regards,

Otto

Ottoooo
  • 25
  • 4

1 Answers1

0

I am not sure if this what you want but you can replace numbers in string with gsub

x <- c("1212", "121neco", "abc")
gsub("[1-9]+", "numbertag", x)

result

[1] "numbertag"     "numbertagneco" "abc" 

if you need to replace them for actual word see @jbgruber comment below your question

jyr
  • 690
  • 6
  • 20