title: $ operator is invalid for atomic vectors in r
body: <p>I am trying to calculate squared residual mean for a model. But I keep getting the error </p>
  
  <blockquote>
    <p>Error in error$residuals : $ operator is invalid for atomic vectors.</p>
  </blockquote>
  
  <p><a href="https://i.stack.imgur.com/fkoQ1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fkoQ1.png" alt="sample data"></a></p>
  
  <pre><code>  attach(delivery_time)
  
    plot(log(`Sorting Time`), `Delivery Time`)
  
    cor(log(`Sorting Time`), `Delivery Time`)
  
    reg &lt;- lm(`Delivery Time` ~ log(`Sorting Time`))
  
    summary(reg)
  
    deliveryer &lt;- predict(reg)
  
    errordelivery &lt;- exp(deliveryer)
  
  
    deliverytime = delivery_time$`Delivery Time`- errordelivery
  
    deliverytime$residuals
  
    sqrt(mean(deliverytime$residuals^2))
  </code></pre>
  
  <blockquote>
    <p><strong>Error in deliverytime$residuals : 
          $ operator is invalid for atomic vectors</strong></p>
  </blockquote>