I R imports columns with no colname as ...1 I need to replace this ... with something else
Trying:
str_replace("hi_...","/././.","&")
Seems like you are trying to replace each dot .
with &
. You need to escape .
as \\.
and use str_replace_all
. Try this,
library(stringr)
str_replace_all("hi_...","\\.","&")
Output,
[1] "hi_&&&"
Just in case you want to replace all three dots with &
(which I barely think you wanted), use this,
str_replace("hi_...","\\.\\.\\.","&")
OR
str_replace("hi_...","\\.+","&")
Another way to achieve same can be using gsub
gsub("\\.", "&", "hi_...")