[R] A question about plots and lists in functions

Greg Snow Greg.Snow at intermountainmail.org
Wed Jun 20 03:57:28 CEST 2007


?invisible

-----Original Message-----
From: "Jason Q McClintic" <jqmcclintic at stthomas.edu>
To: "r-help at stat.math.ethz.ch" <r-help at stat.math.ethz.ch>
Sent: 6/19/07 2:04 PM
Subject: [R] A question about plots and lists in functions

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

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



More information about the R-help mailing list