Skip to content
Prev 65895 / 398513 Next

calling objects in a foreloop

I want to organize outputs from several regressions into a handy table.  When I
try the following, each of my "fit_s" is replaces instead of read.  Is there a
way to read from the regression summaries that does not require writing
separate lines of code for each?
-Ben Osborne
+ dBA.spp16.fits[i,1]<-summary(as.name(paste("fit",i,sep="")))$call
+ dBA.spp16.fits[i,2]<-summary(as.name(paste("fit",i,sep="")))$coef[1,1]
+ dBA.spp16.fits[i,3]<-summary(as.name(paste("fit",i,sep="")))$coef[2,1]
+ dBA.spp16.fits[i,4]<-summary(as.name(paste("fit",i,sep="")))$r.squared
+ dBA.spp16.fits[i,5]<-summary(as.name(paste("fit",i,sep="")))$adj.r.squared
+ }
Error in "[<-"(`*tmp*`, i, 1, value = NULL) :
        number of items to replace is not a multiple of replacement length

# Because:
Length  Class   Mode
     1   name   name