[R] Refer to Data Frame Name Inside a List
Jorge I Velez
jorgeivanvelez at gmail.com
Tue Jun 4 16:37:48 CEST 2013
Try
names(ResList)
HTH,
Jorge.-
Sent from my phone. Please excuse my brevity and misspelling.
On Jun 5, 2013, at 12:34 AM, "Sparks, John James" <jspark4 at uic.edu> wrote:
> 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 ...
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list