Hi:

Perhaps you want this:

f <- function(nbr){
  y<-rnorm(nbr)
  y1 <- mean(y)
  plot(y)
  list(y1 = y1)
 }

f(100)      prints out the mean and executes the plot
w <- f(100)   executes the plot
> w$y1
[1] 0.06965205

returns the mean as a component of the object w.

HTH,
Dennis

On Fri, Feb 19, 2010 at 10:06 AM, threshold <r.kozarski@gmail.com> wrote:

>
> Thank you for response. The problem is that using return(y1) in my function
> formula always returns y1, but what I want is to return it only when I
> wish,
> like p.value in
> t.test(rnorm(100),rnorm(100))$p.value
>
> robert
> --
> View this message in context:
> http://n4.nabble.com/retrieve-from-function-tp1561972p1562012.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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]]

