Hi,

Regarding, ..., you literally just pass ....  For example:

f <- function(d, ...) {
  lapply(d, mean, ...)
}

f(1:10) # but you could pass other arguments to lapply.

Regarding saving, my thought would be to just switch which device is started 
based on path.  I'm sure thre are other, possibly cleverer ways out there.

foo <- function(d, path = NULL, ...) {
  if (!is.null(path)) {
    postscript(paste(path, "plot1.eps", sep=''), other settings)
  } else dev.new()

  barplot(d, ...)

## the postscript device needs to be shutdown
## but if going to default device, probably do not want
## it closed before user can view it
  if (!is.null(path)) dev.off()
}

Hope this helps,

Josh

PS all typed on my phone so expect typos

On Oct 30, 2011, at 14:48, Alaios <ala...@yahoo.com> wrote:

> I am replying to myself as regardless of the save I described below I also 
> want to do something like the following
> 
> do_analysis_for_data_sets <- function(AnalysisFunction, DataSets, ...) {
> �       � lapply(DataSets,AnalysisFunction, "how to pass the ...  to lapply")
> }
> 
> which means that I want to pass the .... also to the lapply (I am using 
> mclapply actually that have the same syntax).
> 
> 
> Could you please comment on that as well as too my point before (About how to 
> write a function that given a path inpuit saves the file as eps)
> 
> 
> B.R
> 
> Alex
> 
> 
> 
> ________________________________
> 
> To: "R-help@r-project.org" <R-help@r-project.org>
> Sent: Sunday, October 30, 2011 9:15 PM
> Subject: [R] Generic Plot and save function
> 
> Dear all,
> 
> I was reading for the nice ... parameter option in R, which if I got it right 
> it is used to pass other parameter to some other function inside your function
> 
> for example
> 
> 
> plot_duty_cycle<- function(data, ...) {
> �� � �  � � �barplot(duty_cycle_per_bin(data), ...)
> }
> 
> I can put some parameters to pass inside the barplot function inside my 
> function.
> 
> 
> I would like to ask you if there is a "smart" way to also put some parameter 
> in the input section of my function so to also save the plot in the given path
> 
> I am thinking for something like that
> 
> plot_duty_cycle<- function(data, ...) {
> �� � �  � � �barplot(duty_cycle_per_bin(data), ...)
> � � � �if (is(path) { save somehow the plot in the path}
> }
> 
> 
> Could you please give me a nice hint for that case
> 
> B.R
> Alex
> ��� [[alternative HTML version deleted]]
> 
> 
> ______________________________________________
> R-help@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.
>    [[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help@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.

______________________________________________
R-help@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.

Reply via email to