title: Create Variables from elements of a List of Lists Automatically R
body: <p>I have a list of lists like below</p>
  <pre><code>str(list_ts_split)
  List of 5
   $ date    :List of 2
    ..$ train: Time-Series [1:24] from 2019 to 2021: 1.55e+09 1.55e+09 1.55e+09 1.55e+09 
  1.56e+09 ...
    ..$ test : Time-Series [1:6] from 2021 to 2021: 1.61e+09 1.61e+09 1.61e+09 1.62e+09 1.62e+09 
  ...
   $ actualB1:List of 2
    ..$ train: Time-Series [1:24] from 2019 to 2021: 5463 7618 3745 6760 5856 ...
    ..$ test : Time-Series [1:6] from 2021 to 2021: 5535 7326 6195 2435 3041 ...
       $ actualB2:List of 2
    ..$ train: Time-Series [1:24] from 2019 to 2021: 6523 1734 9544 4687 8076 ...
    ..$ test : Time-Series [1:6] from 2021 to 2021: 3647 9272 4974 5931 1459 ...
   $ actualAx:List of 2
    ..$ train: Time-Series [1:24] from 2019 to 2021: 193 200 310 149 719 357 470 623 678 533 ...
    ..$ test : Time-Series [1:6] from 2021 to 2021: 274 142 968 831 178 184
   $ actualAy:List of 2
    ..$ train: Time-Series [1:24] from 2019 to 2021: 3053 4351 3284 2155 1805 ...
    ..$ test : Time-Series [1:6] from 2021 to 2021: 8236 1585 2324 5692 4249 ...
  </code></pre>
  <p>I can access the elements of the list of lists using the code below</p>
  <pre><code>df1_tstrain &lt;- list_ts_split$actualB1$train
  
  df1_tstest &lt;- list_ts_split$actualB1$test
  
  list_ts_split $actualB1$train
        Jan  Feb  Mar  Apr  May  Jun  Jul  Aug  Sep  Oct  Nov  Dec
   2019 5463 7618 3745 6760 5856 2645 4061 1162 6829 7584 8383 4016
   2020 2827 1666 3753 2004 1757 9360 5989 9031 1584 1435 8365 9209
  
   list_ts_split$actualB1$test
         Jan  Feb  Mar  Apr  May  Jun
    2021 5535 7326 6195 2435 3041 2737
  </code></pre>
  <p>EDIT1: My question is, is there anyway to create a loop or use a function to do the same as
  df1_tstrain &lt;- actualB1$train      without me hard coding the value to a variable name in the global environment??</p>
  <p>EDIT2:</p>
  <p>I'm trying something like below right now</p>
  <pre><code>for (i in 1:length(list_ts_split)){
  assign(paste0(&quot;tstrain&quot;,i}.as.data.frame(list_ts_split[[i]]))
  }
  </code></pre>