[R] A question about plots and lists in functions

Jason Q McClintic jqmcclintic at stthomas.edu
Tue Jun 19 22:02:08 CEST 2007


R-helpers:

I tried googling and couldn't find anything.

I have a function I am sourcing into R that does some calculations to
generate a simulated dataset. I currently have a a list set up to store
the outputs from the function and a plot of one of them (a set of
ordered pairs) like this:

foo<-function(x,y,z){
## do some work here ##
list(x=x,y=y,z=z,output1=output1,output2=output2,
     plot=plot(output1[,1],output1[,2],type=p));
}

The problem I am having is that when I do

>work<-foo(x,y,z)
>work

it will show the plot, but I would like to be able to repeatedly call it
like I can call the different plots in an lm without having to display
everything else too (in some cases, output1 could be a 50K by 2 matrix,
rather inconvenient to keep having it display that over and over again
to get a graph).

Thanks in advance,

Jason Q. McClintic
--
Jason Q McClintic
jqmcclintic at stthomas.edu
mccl0219 at tc.umn.edu



More information about the R-help mailing list