title: Using lapply to apply functions across lists in R?
body: <p>I have a data frame loaded into R with different values by group:</p>
  
  <pre><code>Group Value
  A     50
  A     2
  A     55
  B     41
  B     60
  B     102
  C     24
  C     60
  C     2
  D     6
  D     9
  D     20
  E     1
  E     23
  E     19
  </code></pre>
  
  <p>I am using a split function to split the data by group:</p>
  
  <pre><code>mylist &lt;- split(mydata, mydata$Group)
  mylist
  </code></pre>
  
  <p>I am then creating an auto.arima function that works and returns ARIMA output when I run it on an individual group (with the group already being loaded into R as a separate dataframe):</p>
  
  <pre><code>arm &lt;- function(x) auto.arima(x)
  forecastarm=arm(myTableA$Value)
  </code></pre>
  
  <p>However, what I want to do is use the ARIMA function to calculate ARIMA on all the groups in the dataset automatically. However, I am unsure how to use lapply to do this.</p>
  
  <p>I have tried:</p>
  
  <pre><code>allarima &lt;- lapply(mylist,arm)
  </code></pre>
  
  <p>However, it does not seem to be running the ARIMA models separately across group like I want, as I am getting the error message:</p>
  
  <pre><code>Error in auto.arima(x) : No suitable ARIMA model found
  </code></pre>
  
  <p>Would be grateful for any help on how to use lapply correctly with the function. Many thanks.</p>