Hello Steve,

On Thu, Jul 16, 2009 at 2:28 AM, S Ellison<s.elli...@lgc.co.uk> wrote:
> Auto-updating sounds hard in R for a 'regular' data frame. You could
> perhaps define an entirely new class of object and define data
> entry/indexing methods so that, say, they sought functions in an
> attribute defined as a list of lists of the form (target, source, fun)
> and inserted the result of applying function fun to column name(s)
> source into a column named target. But I've not tried it, and you'd have
> to work out how to append, update and delete the functions as well as
> work out all the possible entry/indexing operators in order to make sure
> you caught all the possibilities for messing up. Sounds nasty.
>
Nasty indeed.


> Much simpler to write your row drop as something simple like
> y.clean<-subset(y, y$bad|y$worse)
> where $bad and $worse are your two 'drop me' flag columns.
>
An(other) efficient solution to the second part of the problem. Now
for this specific case of flagging for removal I no longer need a
third logical, and autoupdating; I can use all relevant variables in
one call. I settled for the following syntax:
> dim(tmp.obj)   #original object
[1] 35771    28
> dim(subset(tmp.obj, !tmp.obj$dupl.yr & !tmp.obj$unmat.yr))   #object 
> subsetted using the twocols
[1] 35737    28
> dim(subset(tmp.obj, !tmp.obj$rm.yr))   #object subsetted using the third 
> logical
[1] 35737    28

I needed to replace "|" with "&" to get this result. I'm also negating
the logicals, since I have TRUE for "remove".
Thank you
Liviu

______________________________________________
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.

Reply via email to