Re: [R] looping through data frames in a workspace

From: Martin Elff <elff_at_sowi.uni-mannheim.de>
Date: Tue, 04 Mar 2008 10:10:31 +0100

On Monday 03 March 2008 (23:28:05), lucy b wrote:
> I would like to avoid having to type-out a very long list over and
> over again. I have tried every variation I could think of similar to:
>
> for(df in list(noquote(ls()))) {
>
>      do stuff with df
>
>      }
>
> I know this has to be possible. What am I missing?

I guess something like the following will do what you want, but I am not completely sure ...

for(dfname in ls()){
 eval(substitute({

		<do stuff with df>
		},
      		list(
		  df=as.name(dfname)
		  )
     		)
      )
	

}

HTH,
Martin



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. Received on Tue 04 Mar 2008 - 09:27:06 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 04 Mar 2008 - 09:30:18 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive