You have to 'get' the object that you have a character string for; e.g.,
for (df in c('a1', 'b3', 'c7')){
print(get(df))
}
see ?get
On 12/23/06, jingjiang yan <jingjiangyan@gmail.com>
wrote:>
> Hi, people
> I am just new to R, when writing my loop functions, I meet a problem.
> There are some data frames, their names is randomized, ( e.g. a1,b3,c7,
> etc), what should I write it when I want to see them printed together in a
> loop function? I have tried :
>
> > for ( df in 'a1','b3','c7') {
> + print(print(df))
> + }
> the results are:
> "a1" "b3" "c7"
>
> but what I want is the results of
> > print(a1);print(b3);print(c7);
> so, could anyone give suggestion?
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@stat.math.ethz.ch 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.
>
--
Jim Holtman
Cincinnati, OH
+1 513 646 9390
What is the problem you are trying to solve?
[[alternative HTML version deleted]]