title: Efficient way to calculate average MAPE and MSE in R
body: <p>I have a real data and predicted data and I want to calculate overall MAPE and MSE. The data are time series, with each column representing data for different weeks. I predict value for each of the 52 weeks for each of the items as shown below. What would be the best possible calculate overall Error in R.</p>
  
  <pre><code>real = matrix( 
      c("item1", "item2", "item3", "item4", .5, .7, 0.40, 0.6, 0.3, 0.29, 0.7, 0.09, 0.42, 0.032, 0.3, 0.37), 
       nrow=4, 
       ncol=4) 
  colnames(real) &lt;- c("item", "week1", "week2", "week3")
  
  
  predicted = matrix( 
    c("item1", "item2", "item3", "item4", .55, .67, 0.40, 0.69, 0.13, 0.9, 0.47, 0.19, 0.22, 0.033, 0.4, 0.37), 
    nrow=4, 
    ncol=4) 
  colnames(predicted) &lt;- c("item", "week1", "week2", "week3")
  </code></pre>