title: Extracting mentions, hashtags and, urls and placing them in a new column in a Twitter Dataset with R
body: <p>I have a Twitter dataset of 30000 tweets and I'm trying to prepare the data for text analysis. I downloaded the dataset with academictwitteR package in R. Inside the dataset, some columns (such as; &quot;user.metrics&quot;, &quot;public.metrics&quot;, &quot;entities&quot; are seperate data frames. I managed to extract  the columns from &quot;user.metrics&quot; and &quot;public.metrics&quot; and merge the extracted columns with my original dataset as following, without a problem;</p>
  <pre><code>#extract
  extract_publicmetrics &lt;- as.data.frame(mytwitterdata$public_metrics)
  colnames(extract_publicmetrics)
  [1] &quot;retweet_count&quot; &quot;reply_count&quot;   &quot;like_count&quot;    &quot;quote_count&quot;
  
  #add observation column to bind with the original data (mytwitterdata)
  addconsecutivenumbers1 &lt;- cbind(extract_publicmetrics, &quot;observation&quot;=1:nrow(deneme2_publicmetrics)) 
  addconsecutivenumbers2 &lt;- cbind(mytwitterdata, &quot;observation&quot;=1:nrow(joined_deneme2))
  #merge two data
  merged.data &lt;- merge(addconsecutivenumbers1, addconsecutivenumbers2, by=&quot;observation&quot;)
  </code></pre>
  <p>But, I could not manage to extract &quot;mentions&quot;, &quot;urls&quot;, &quot;hastags&quot; columns from &quot;Entities&quot; dataframe in my dataset.I think it's because &quot;mentions&quot;, &quot;urls&quot;, &quot;hashtags&quot; are nested lists in that data frame (e.g.):</p>
  <pre><code>class(mytwitterdata$entities$hashtags)
  [1] &quot;list&quot;
  </code></pre>
  <p>For example, a Tweet may contain no hashtag, one hashtag, or more than one hashtag. I want to create a new column from that list in which the value of the row is NA when there is no hashtag, or the row includes the hashtag as text in the row ( or hashtags separated with commas when it includes more than one hashtag).</p>
  <p>Attached is s sample data of 10 rows extracted from the &quot;Entities&quot; dataframe from my dataset:</p>
  <p><a href="https://drive.google.com/file/d/1vfyFIObRS9tCxGNJCG9AMyKgxwgwBDMZ/view?usp=sharing" rel="nofollow noreferrer">https://drive.google.com/file/d/1vfyFIObRS9tCxGNJCG9AMyKgxwgwBDMZ/view?usp=sharing</a></p>