title: How to create dataframes iterating over a list of names?
body: <p>I have this dataframe:</p>
  
  <pre><code>x = data.frame("city" = c("Madrid","Berlin","Florence","Madrid"), 
  "Visits" = c(100,200,80,38), "Date" = c(1,2,3,4))
  </code></pre>
  
  <p>From that sample, I would like to obtain 3 dataframe (one for each city) with all the values containing that city and named as that city without the column city, so it would result in the following:</p>
  
  <pre><code>Madrid = data.frame("Visits" = c(100,38), "Date" = c(1,4))
  Berlin = data.frame("Visits" = c(200), "Date" = c(2)
  Florence = data.frame("Visits" = c(80), "Date" = c(3))
  </code></pre>
  
  <p>I asked the same question in pandas: <a href="https://stackoverflow.com/questions/51366343/how-to-create-dataframes-iterating-over-a-set">How to create dataframes iterating over a set?</a> but I cannot find something similar to dictionary comprehension. </p>
  
  <p>I have managed to get the unique list and to get the values of a city:</p>
  
  <pre><code>cities = unique(select(x,city))
  for (i in cities){
    dplyr::filter(x,city == i)}
  </code></pre>
  
  <p>I know that loops should not be used in R and apply is more efficient, but I dont know how could I do that using apply. I am open to other data structures (and not dataframes for each city) as long as I am able to access them easily to pass other functions (auto.arima for instance). Thank you very much</p>