'How to deal with nested data frames

I am having a problem on how to get a certain value for each row in my dataframe. More precisely, it is about the variable entities.urls whose values again consist of variables

Dataframe

entities.urls consists of the following variables: start, end, url, expanded_url and display_url etc. Variables within entities.url:

img

I need to get the second entry of the expanded_url variable that is embedded in the entities.urls variable for each row in my original dataframe. To give you some context: I want to get the expanded url for each tweet.

I have not figured out any way to solve this issue and I would highly appreciate any help.

The structure of my dataframe is the following:

glimpse(data2)

[Output]: 
Rows: 66
Columns: 28
$ entities.urls                  <list> [<data.frame[2 x 5]>], [<data.frame[2 x 5]>], [<data.fram~
$ id                             <chr> "1498290646406340615", "1498234776737792000", "14982113720~ ....

The entities.urls dataframe consists of the following:

str(entities_urls)

[Output]
List of 66
 $ :'data.frame':   2 obs. of  5 variables:
  ..$ start       : int [1:2] 240 264
  ..$ end         : int [1:2] 263 287
  ..$ url         : chr [1:2] "shortened url not allowed" "shortened url not allowed"
  ..$ expanded_url: chr [1:2] "shortened url not allowed" **"https://twitter.com/Agilent/status/1498290646406340615/photo/1**"
  ..$ display_url : chr [1:2] "bit.ly/3qDpMxH" "pic.twitter.com/Re4DtJ7U2z" 


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source