I want the coefficients looped across all the columns of data frame. I want to save this output into a variable which I can place into a data frame, where all the values can be placed into one column.
Printed output shows many NA's. How can this be removed in the process.
So something like:
Co_data <- (Looped values)
Example of code:
mod1 <- lm(starling_farm ~ years, data = L_farmland_frame)
for(i in colnames(L_population.frame)){
print(c(mod1$coefficients[i], 
mod2$coefficients[i], 
mod3$coefficients[i], 
mod4$coefficients[i], 
mod5$coefficients[i], 
mod6$coefficients[i], 
mod7$coefficients[i], 
mod8$coefficients[i], 
mod9$coefficients[i], 
mod10$coefficients[i], 
mod11$coefficients[i], 
mod12$coefficients[i], 
mod13$coefficients[i], 
mod14$coefficients[i], 
mod15$coefficients[i], 
mod16$coefficients[i],
mod17$coefficients[i]))} ```
Output value:
```years       years       years       years       years 
-0.17263280 -0.16783959  0.04566027 -0.11492727 -0.11345848 
      years       years       years       years       years 
-0.15713866 -0.11703737 -0.08202416 -0.25307321 -0.07794717 
      years       years       years       years       years 
-0.07591691 -0.12998199 -0.10227772 -0.03500562 -0.10366356 
      years       years 
-0.13475428 -0.14861171 
<NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> 
  NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA 
<NA> <NA> <NA> <NA> <NA> 
  NA   NA   NA   NA   NA 
<NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> 
  NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA 
....
....
 
     
    