[R] Refer to Data Frame Name Inside a List

Sparks, John James jspark4 at uic.edu
Tue Jun 4 16:33:25 CEST 2013


Dear R Helpers,

I have a fairly complicated list of data frames.  To give you an idea of
the structure, the top of the str output is shown below.

How do I refer to the data.frame name for each data.frame in the list? 
That is, how can I pull the terms Advertising2007, AirFreightDelivery2007,
Apparel2007 etc. out of the list?  I need them to keep track of
correlations that I am doing inside each data frame of the list.

Apologies for not sending a reproducible example.  I am hoping that
someone knows this off the top of their head.

--John Sparks

> str(ResList)
List of 60
 $ Advertising2007         :'data.frame':       21 obs. of  10 variables:
  ..$ RFPred       : num [1:21] -0.01749 -0.00801 -0.01155 -0.01494
-0.03715 ...
  ..$ marsPred     : num [1:21] 0.0901 0.0127 0.0616 0.0618 -0.0559 ...
  ..$ GainRepAft3  : num [1:21] -0.0673 -0.0183 -0.2353 0.0294 -0.059 ...
  ..$ Industry     : chr [1:21] "Advertising2007" "Advertising2007"
"Advertising2007" "Advertising2007" ...
  ..$ dateavail    : Factor w/ 346 levels "2008-02-01","2008-02-13",..: 18
4 14 12 13 19 1 15 17 8 ...
  ..$ FinYearEnd   : Factor w/ 12 levels "2007-12-01","2007-03-01",..: 1 1
1 1 1 1 1 1 1 1 ...
  ..$ GainAft1Aft30: num [1:21] -0.2376 -0.1384 -0.1176 0.0145 0.0527 ...
  ..$ GainAft1Aft60: num [1:21] -0.36212 -0.17801 -0.23529 -0.00501
-0.27414 ...
  ..$ GainAft1Aft90: num [1:21] -0.516 -0.203 -0.176 0.024 -0.241 ...
  ..$ groups       : Factor w/ 40 levels "-0.04013239",..: 4 11 8 6 1 1 10
13 2 5 ...
 $ AirFreightDelivery2007  :'data.frame':       20 obs. of  10 variables:
  ..$ RFPred       : num [1:20] 0.00322 -0.00351 0.034 0.01095 0.02237 ...
  ..$ marsPred     : num [1:20] -0.013 -0.109 0.0662 0.0353 0.0662 ...
  ..$ GainRepAft3  : num [1:20] 0.0344 -0.0659 0.054 0.045 0.0266 ...
  ..$ Industry     : chr [1:20] "AirFreightDelivery2007"
"AirFreightDelivery2007" "AirFreightDelivery2007"
"AirFreightDelivery2007" ...
  ..$ dateavail    : Factor w/ 346 levels "2008-02-01","2008-02-13",..: 22
10 26 33 35 32 25 23 31 10 ...
  ..$ FinYearEnd   : Factor w/ 12 levels "2007-12-01","2007-03-01",..: 2 1
1 1 1 1 1 3 1 1 ...
  ..$ GainAft1Aft30: num [1:20] -0.0656 -0.1539 -0.1002 -0.0694 -0.4101 ...
  ..$ GainAft1Aft60: num [1:20] -0.133 -0.141 -0.242 -0.691 -0.212 ...
  ..$ GainAft1Aft90: num [1:20] -0.0523 -0.0673 -0.1793 -0.6875 -0.187 ...
  ..$ groups       : Factor w/ 40 levels "-0.04013239",..: 24 16 39 32 37
21 17 30 35 37 ...
 $ Apparel2007             :'data.frame':       28 obs. of  10 variables:
  ..$ RFPred       : num [1:28] 0.011439 0.021311 0.014564 0.018168
-0.000892 ...
  ..$ marsPred     : num [1:28] -0.001463 0.0345 0.027227 -0.000129
-0.006483 ...



More information about the R-help mailing list