title: r Error dim(X) must have a positive length?
body: <p>I want to compute the mean of "Population" of built-in matrix <code>state.x77</code>. The codes are :</p>
  
  <pre><code>apply(state.x77[,"Population"],2,FUN=mean)
  
  #Error in apply(state.x77[, "Population"], 2, FUN = mean) : 
  
  # dim(X) must have a positive length
  </code></pre>
  
  <p>how can I prevent this error? If I use <code>$</code> sign </p>
  
  <pre><code>apply(state.x77$Population,2,mean)
  # Error in state.x77$Population : $ operator is invalid for atomic vectors
  </code></pre>
  
  <p>What is atomic vector?</p>