s-news
[Top] [All Lists]

Re: Filling a vector at some places

To: "'Andre.Mery@aventis.com'" <Andre.Mery@aventis.com>, s-news@lists.biostat.wustl.edu
Subject: Re: Filling a vector at some places
From: "Liaw, Andy" <andy_liaw@merck.com>
Date: Wed, 29 Sep 2004 08:02:37 -0400
vec1[vec2] <- 1 ought to do it, or is that not what you want?
 
HTH,
Andy
-----Original Message-----
From: s-news-owner@lists.biostat.wustl.edu [mailto:s-news-owner@lists.biostat.wustl.edu] On Behalf Of Andre.Mery@aventis.com
Sent: Wednesday, September 29, 2004 7:34 AM
To: s-news@lists.biostat.wustl.edu
Subject: [S] Filling a vector at some places

Hi,
 
I am stuck by the following problem.
 
I have a vector with 36 positions, all set to 0:
vec1 =  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Now, after some other calculations, I get a the vector:
vec2 = 18  1  5  2
And so, I want to transform the vec1 to a vec3:
 vec3 =  1 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
where 1s appear at the places indicated by vec2 (places # 1, 2, 5 and 18)
I can't find a simple way to do so. Can anyone enlighten me ?
 
 
 

André Méry
Aventis Pharma
20, avenue Raymond Aron - 92160 Antony
[Courrier / Mail : Tri B2/13]
[Tél. / Tel. : 01 55 71 68 69]

 

------------------------------------------------------------------------------
Notice: This e-mail message, together with any attachments, contains information of Merck & Co., Inc. (One Merck Drive, Whitehouse Station, New Jersey, USA 08889), and/or its affiliates (which may be known outside the United States as Merck Frosst, Merck Sharp & Dohme or MSD and in Japan, as Banyu) that may be confidential, proprietary copyrighted and/or legally privileged. It is intended solely for the use of the individual or entity named on this message. If you are not the intended recipient, and have received this message in error, please notify us immediately by reply e-mail and then delete it from your system.
------------------------------------------------------------------------------

<Prev in Thread] Current Thread [Next in Thread>