Try
y1[(dummy==0) & (y1 < y2)] <- y2[(dummy==0) & (y1<y2)]
Pete
____________________________________________
Peter M. Meyer, PhD
Visiting Scholar, Johns Hopkins School of Public Health
Assistant Professor and Director, Section of Biostatistics
Department of Preventive Medicine
Rush-Presbyterian-St. Luke's Medical Center
Rush University
1700 W. Van Buren, Suite 470
Chicago, Illinois 60612-3244
Phone 312-942-2337
Fax 312-942-7224
----- Original Message -----
From: "Talukder, Enayet" <enayet_talukder@groton.pfizer.com>
To: <s-news@lists.biostat.wustl.edu>
Sent: Friday, April 18, 2003 10:20 PM
Subject: [S] Programming Help!
> Dear S-Plus users:
>
> I have three variables :
>
> Y1 Y2 dummy
> 1.2 1.0 1
> 1.4 1.5 0
> 1.5 0.9 1
> 1.7 1.9 1
> 1.9 1.7 0
>
> I like to replace those elements of Y1 by the elements of Y2 for which
> dummy=0 if these elements of Y1 are smaller than the corresponding
elements
> of Y2.
> That is, I like to have the resultant new Y1 as
>
> Y1
> 1.2
> 1.5
> 1.5
> 1.7
> 1.9
>
> Please notice that the second element of new Y1 is not 1.4 any more but
> replaced by the second element of Y2 [dummy==0]. However, the last element
> of Y1 is not replaced by the corresponding element of Y2 even though
> corresponding dummy=0 as 1.9> 1.7.
>
> How can I accomplish this? I am using S+ 2000.
>
> Any help will be appreciated.
>
> Regards,
> Enayet
>
>
>
> LEGAL NOTICE
> Unless expressly stated otherwise, this message is confidential and may be
privileged. It is intended for the addressee(s) only. Access to this E-mail
by anyone else is unauthorized. If you are not an addressee, any disclosure
or copying of the contents of this E-mail or any action taken (or not taken)
in reliance on it is unauthorized and may be unlawful. If you are not an
addressee, please inform the sender immediately.
> --------------------------------------------------------------------
> This message was distributed by s-news@lists.biostat.wustl.edu. To
> unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
> the BODY of the message: unsubscribe s-news
|