I have a dataset naked named data
in R with n variables, namely X1,X2,...,Xn
. At some point of my code i find a subset named subs
from another procedure, that gives the following output
X1 X7 X8 X9 X11
1 440.8065 466.9053 60.03588 374.8059 167.2424
Note that Xi values are not the same values from data
and each Xi
is the header, not a row in R.
For each of those Xi
there are saved in the environment dataframes named VarXi
(e.g. VarX1, VarX2,..., VarXn
) of this form
variable coefficient
1 (Intercept) -2.111150e+03
2 X3 2.797371e-05
3 X5 5.653977e-01
4 X6 5.660470e+00
5 X7 1.003460e+01
6 X8 2.403519e+01
7 X10 3.931899e-01
8 X12 2.062661e+00
9 X13 5.430814e+00
10 X14 2.433546e-01
I want firstly to create a new dataset newdata
that contains only the variables displayed in subs
, and secondly (and most importantly) for only those VarXi
displayed in subs
to print only the the abs(maximum coefficient)
and the corresponding variable of first column, eg.g based on above example
variable coefficient
1 X6 5.660470
How can i do those things in R?