[R] (Newbie) scope of with()

From: Antonio Prioglio <a.prioglio_at_city.ac.uk>
Date: Thu 15 Jul 2004 - 18:01:53 EST


Hi list,
As I understand statements within with() are local to what is enclosed within its expression.

As some excellent examples given to me previously have illustrated it is nevertheless possible to assign the evaluation of an expression to an external variable like x <- with(data, if(..))

During a "normalisation" phase of data read from a database I have a long list of statements of the type
participant$longfieldname[is.na(participant$longfieldname)]<-expr(...) or similar that makes cumbersome reading. (participant is a table of demographic data)

If there a neat way to do something of the sort "participant<-with(participant,{...})"

it would make nicer reading.

Apparently attach(), detach() would not do as fieldname<-expr(fieldname)
creates a new variable and not a change to the value of the field!

Saluti,
Antonio Prioglio

-- 
We are what we repeatedly do. Excellence, then, is not an act, but a habit.
							Aristoteles


    /"\
    \ /    ASCII RIBBON CAMPAIGN - AGAINST HTML MAIL 
     X                           - AGAINST MS ATTACHMENTS
    / \

http://www.gnu.org/philosophy/no-word-attachments.html

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Thu Jul 15 18:10:09 2004

This archive was generated by hypermail 2.1.8 : Fri 18 Mar 2005 - 02:36:33 EST