v<-c("RT @name1: hello world", "Hi guys, how are you?", "Hello RT I have no text", "RT @name2: Hello!")
我只想删除位于字符串开头的RT
并将结果存储在另一个向量中,例如w
:
> w
"@name1: hello world" "Hi guys, how are you?" "Hello RT I have no text" "@name2: Hello!"
也许我可以使用软件包str_extract_all
中的函数stringr
,但无法将其应用于我的问题。
我具有以下字符串向量:v
gsub
和'anchor'^
,它表示字符串的开头:<- str_replace(v,"^RT","")