I'm trying to get mentions on twitter data like @someone @somebody from a data frame twitter and creating a new data frame with the information of who tweeted and which people they mentioned.
Example:
tweets <- data.frame(user=c("people","person","ghost"),text = c("Hey, check this out
@somebody @someone","love this @john","amazing"))
Resulting on this data frame:
**user text**
*people Hey, check this out @somebody @someone*
*person love this @john*
*ghost amazing*
The desired result is:
**id mention**
*people @somebody*
*people @someone*
*person john*
*ghost*
Can you guys help me , please?
You can do something like this by using library
stringr
:Output is as follows:
To get the output in long format, you can do something like this:
Output is as follows: