[R] spreadsheet-style autoupdating

Charles C. Berry cberry at tajo.ucsd.edu
Wed Jul 15 23:26:50 CEST 2009


On Wed, 15 Jul 2009, Liviu Andronic wrote:

> Hello Patrick,
>
> On 7/15/09, Patrick Burns <pburns at pburns.seanet.com> wrote:
>> How about something along the lines of:
>>  apply(twocolumns, 1, any)
>>
> This efficiently solves the first part of my question. I will probably
> content myself with issuing this command each time I update one of the
> "twocolumns"; I'm still curious whether R can store this function in
> the third column, and autoupdate it whenever one of the "twocolumns"
> gets modified (behaviour very similar to that of spreadsheets),
> although I'd doubt R could.

Well, I am 'thinking out loud' here, so you've been warned...

The open.account() example in Intro to R 10.7 shows how you might do 
updates in a very structured (and limited) way. You specify how all the 
updates are done (e.g. of 'total' in that example) in advance of creating 
any objects and keep the objects in an environment whose objects are only 
modified thru a function along the lines of open.account().

---

Another approach is to define a class 'revised-by-another' (say) that 
marks objects that may be modified by changes in other objects and another 
class 'revises-another' that marks objects upon which some 
'revised-by-another' object depends. When '[.revises.another' or 
'[[.revises.another' is called, a search is triggered for objects 
inheriting 'revised-by-another' and a graph of revisions is defined and 
then executed. That graph would need to account for dependencies in which 
a change in X3 changes X2 and X1, but X1 explicitly depends on both X2 and 
X3 (so X2 needs to be modified before X1).

---

Another (related) approach would use the 'make' utility to manage updates 
and construct the graph mentioned in the previous paragraph. I vaguely 
recall seeing something about this - maybe a package - but I cannot lay my 
hands on it. (Then, too, there is 'weaver' on bioconductor that provides 
some related functionality.)

HTH,

Chuck


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

Charles C. Berry                            (858) 534-2098
                                             Dept of Family/Preventive Medicine
E mailto:cberry at tajo.ucsd.edu	            UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901




More information about the R-help mailing list