[R] multiple graphs, lapply and different titles

David Winsemius dwinsemius at comcast.net
Fri Oct 19 23:33:58 CEST 2012


On Oct 19, 2012, at 12:30 PM, Flavio Barros wrote:

> I have a list of data.frames, and i want to iterate over this list and
> generate graphs with the same title of the data.frame.
> 
> I did the graphs with:
> 
> lapply(anual, function(x) plot(x[,'chuva'], type='l', xlab= 'anos', ylab =
> 'Precicipatação(mm)', col='red'))
> 
> where anual is list of data.frames. I am plotting just the column "chuva"
> at each data.frame.
> 
> How can i do that?

Easiest way would be to iterate over the names of the list 'anual' and then use nam as your formal argument,  pull each data.frame in from 'anual' with anual[nam] and use main=nam in the plot command.

> and provide commented, minimal, self-contained, reproducible code.

Had you provided a self-contained example I would have offered tested code in return.

-- 

David Winsemius, MD
Alameda, CA, USA




More information about the R-help mailing list