Sachin
Sachin

Reputation: 145

Unable to remove these characters from the data in a string in r

I am trying to remove the special character from the following string with the help of following code , but not getting the result :

library(tm)

v <- "rt shibxwarrior hodl  trust  processsome great things    horizon folks    shib \n\nshib shiba shibainu shibar…"

 t <- "[\n~@!#$%&*…[]'=;]"

removespl_character <- function(x)gsub('t','',x)

cleanset_t <- tm_map(v,removespl_character)

Please help me on this.. thanks a lot

Upvotes: 0

Views: 204

Answers (1)

DataM
DataM

Reputation: 351

I've changed the pattern to this :

 v <- "rt ~@!#$%&*…[]'=; shibxwarrior[] hodl  trust  processsome great things    horizon folks    shib \n\nshib shiba shibainu shibar…"
t <- "[~@\\!#\n$%&\\*…\\'=;]|\\]|\\["

v
gsub(pattern = t, replacement = "", x = v)

I copied your input :

v <- "rt shibxwarrior hodl  trust  processsome great things    horizon folks    shib \n\nshib shiba shibainu shibar…"
t <- "[~@\\!#\n$%&\\*…\\'=;]|\\]|\\["

v
gsub(pattern = t, replacement = "", x = v)

Upvotes: 1

Related Questions