I have 30 tables I created. Their names are structured as follows:
mdl_(race)_(wage quartile).
(race) is one of the following: whites, blacks, hispanics, asians, others, or all.
(wage quartile) is one of the following: Q1, Q2, Q3, Q4, and allQ.
Since I have 6 race categories and 5 wage quartiles, I have 6*5 = 30 objects!
- Ex: Linear model that includes only hispanics in the 1st quartile of wage distribution => mdl_hispanics_Q1
- Ex: Linear model that includes all races and all wage quartiles => mdl_all_allQ
All tables are formatted identically, with different values of course:
Variables Estimate Std. Error t value Pr(>|t|)
1: Intercept 37.231178895 9.486380e-02 392.469814 0.000000e+00
2: forborn -0.612941167 5.174224e-02 -11.846051 2.300944e-32
3: female -3.238655089 4.797890e-02 -67.501655 0.000000e+00
4: numchild 0.583390602 2.239027e-02 26.055543 1.841656e-149
5: numchild_female 0.371351058 9.086739e-02 4.086736 4.376191e-05
6: hs 0.173864095 9.180975e-02 1.893743 5.826025e-02
7: somecol 0.595612050 9.407851e-02 6.331011 2.439689e-10
8: college 1.593917949 9.929766e-02 16.051918 5.923264e-58
9: advanced 0.171443556 1.983952e-03 86.415175 0.000000e+00
10: rw -0.001207904 1.460021e-05 -82.731964 0.000000e+00
11: rw_squared -0.954029880 3.252520e-02 -29.332024 8.456547e-189
What I want to do is get a numeric vector with 30 values, where each value is the estimate for the variable "forborn" if its statistically significant Pr(>|t|) < 0.1 and zero otherwise. I am a beginner to R, and only know how to do this table by table. This is painfully tedious and takes up so much code. Is there a way I could take advantage of the fact the tables are named similarly and loop this operation in one sweep?
tables()in the data.table packages that summarizes all the existing data.tables- you can use it withmget