I have a column that contains multiple tweets:
ID | Tweet
1 @ChipotleTweets @ChipotleTweets Becky is very nice
2 Happy Halloween! I now look forward to $3 booritos at @ChipotleTweets
3 Considering walking to @.ChipotleTweets in my llama onesie.
The goal is to remove the '@___' and anything that is after @ - but not the text spaced outside that string.
Playing around this code currently to detect '@' but I am not picking up anything if it's not in the first position of the sentence
tweet_pattern <- " @\\w+"
Customer <- Customer %>%
clean_Tweet = ifelse(str_detect(text, tweet_pattern),
str_remove(text, tweet_pattern),
NA_character_))
Desired output:
ID | Tweet | cleaned_tweet
1 @ChipotleTweets @ChipotleTweets Becky is very nice Becky is very nice
2 Happy Halloween! I now look forward to $3 booritos at @ChipotleTweets Happy Halloween! I now look forward to $3 booritos at
3 Considering walking to @.ChipotleTweets in my llama onesie. Considering walking to in my llama onesie.