| To: | Bill.Venables@CMIS.CSIRO.AU |
|---|---|
| Subject: | Re: indexing feature (WAS indexing within a list using Splus |
| From: | Patrick Burns <pburns@pburns.seanet.com> |
| Date: | Mon, 28 Oct 2002 12:46:58 +0000 |
| Cc: | ripley@stats.ox.ac.uk, Nick.Ellis@csiro.au, s-news@wubios.wustl.edu |
| References: | <E09E527B56BE2D438A3D6A246DDD27A91655D7@Roper-CV.qld.cmis.csiro.au> |
| User-agent: | Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.4) Gecko/20011126 Netscape6/6.2.1 |
|
Here is a specific example of what nerdy ole' Bill is talking about. When making plots for publications, I like to write functions that create the plots. This means that months or years later there is no mucking about trying to find how precisely that plot was made -- the data are stored inside the function along with the plot commands. The first step is to create a template function: P.template <- function(file="xxx.eps") { x <- 234 if(length(file)) { # set up hardcopy plotting commands } else { # set up plotting to a window } plot(x) } Then create a specific instance: P.description <- P.template Then specialize the instance: P.description[[c(2,1,2)]] # make sure I have the right spot, should be 234 P.description[[c(2,1,2)]] <- the.real.x.object P.description(NULL) # look to see how well it works P.description() # creates the file, the name in the function should be edited In R, functions are not visibly lists like this (as well as R not having this form of subscripting). The same thing can be done in R of course (it is still S after all), but not as neatly to my knowledge. Patrick Burns pburns@pburns.seanet.com http://www.seanet.com/~pburns/Spoetry http://www.i-way.co.uk/~pat/Spoetry Bill.Venables@CMIS.CSIRO.AU wrote: Just a minor footnote to Brian's reply below. The only place where this |
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | A "list" of problems!, Steve Su |
|---|---|
| Next by Date: | Re: Ranking rows of a matrix (summary), David . Jessop |
| Previous by Thread: | Re: indexing feature (WAS indexing within a list using Splus, Steve Su |
| Next by Thread: | Multiple comparisons, Joanne Dingle |
| Indexes: | [Date] [Thread] [Top] [All Lists] |