title: Residual standard error: NaN on 0 degrees of freedom getting this error while creating a linear model
body: <p>I am creating a linear model from a data frame in which column 6 depends on column 1 to 5. Although the code executes properly, when I print the summary of the linear model I get the following.</p>
  
  <pre><code>Call:
  lm(formula = AAPL[, 6] ~ AAPL[, 1] + AAPL[, 2], data = AAPL[, 
      c(1, 2)], subset = 1)
  
  Residuals:
  ALL 1 residuals are 0: no residual degrees of freedom!
  
  Coefficients: (2 not defined because of singularities)
              Estimate Std. Error t value Pr(&gt;|t|)
  (Intercept)    8.104         NA      NA       NA
  AAPL[, 1]         NA         NA      NA       NA
  AAPL[, 2]         NA         NA      NA       NA
  
  Residual standard error: NaN on 0 degrees of freedom
  </code></pre>
  
  <p>The code I am using :-</p>
  
  <pre><code>lm &lt;- lm(train[,6] ~ train[,2]+train[,3]+train[,4]+train[,5]+train[,1] , 1 , data=train)
  </code></pre>
  
  <p><strong>PS:</strong> If I remove the part <strong>data=train</strong> then this works in terminal but not when executed from file.</p>
  
  <p>The next line of code which is almost same except one parameter runs perfectly.The next line is:</p>
  
  <pre><code>lm2 &lt;- lm(train[,6] ~ train[,2]+train[,3]+train[,4]+train[,5]+train[,1] , 5)
  </code></pre>