Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><code>Map</code> can be used to solve that problem: </p> <pre><code>mydata&lt;-mtcars dep&lt;-as.list(rep("mpg~",(dim(mydata)[2]-1))) # ldependent variables with ~ indep1&lt;- as.list( names(mydata)[-1]) indeno&lt;-as.list(1:(dim(mydata)[2]-1)) myreg&lt;-Map(function(x,y) (lm(as.formula(paste(x,paste(unlist(indep[1:y]),collapse="+"))),data=mtcars))$coefficient,dep,indeno) &gt; myreg [[1]] (Intercept) cyl 37.88458 -2.87579 [[2]] (Intercept) cyl disp 34.66099474 -1.58727681 -0.02058363 [[3]] (Intercept) cyl disp hp 34.18491917 -1.22741994 -0.01883809 -0.01467933 [[4]] (Intercept) cyl disp hp drat 23.98524441 -0.81402201 -0.01389625 -0.02317068 2.15404553 [[5]] (Intercept) cyl disp hp drat wt 36.00835689 -1.10748650 0.01235733 -0.02401743 0.95220742 -3.67328708 [[6]] (Intercept) cyl disp hp drat wt qsec 26.30735899 -0.81856023 0.01320490 -0.01792993 1.32040573 -4.19083238 0.40146117 [[7]] (Intercept) cyl disp hp drat wt qsec vs 25.88354175 -0.85665309 0.01314097 -0.01733070 1.31265550 -4.22434351 0.44873351 -0.27816899 [[8]] (Intercept) cyl disp hp drat wt qsec vs am 15.57313068 -0.27859352 0.01471012 -0.02144242 0.81505862 -3.94373934 0.80975689 0.36835866 2.79374984 [[9]] (Intercept) cyl disp hp drat wt qsec vs am 12.83083549 -0.16881263 0.01623358 -0.02424055 0.70590083 -4.03214213 0.86828517 0.36470431 2.55092849 gear 0.50293618 [[10]] (Intercept) cyl disp hp drat wt qsec vs am 12.30337416 -0.11144048 0.01333524 -0.02148212 0.78711097 -3.71530393 0.82104075 0.31776281 2.52022689 gear carb 0.65541302 -0.19941925 </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload