s-news
[Top] [All Lists]

simple vector question

To: s-news@wubios.wustl.edu
Subject: simple vector question
From: Eric yang <yang_eric9@yahoo.com>
Date: Wed, 12 Oct 2005 08:32:18 -0700 (PDT)
Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=sWkpp3waoE8IVF0yedqB5bwryzC9f2IWMd/wlLze99m+NQcKJe7LzIE8O0guCpbtu10K21i+EZF9RvmsR345i7urhuU0HFtr6eQQaHAO1dhBinb5wkocb2vjNScNM8sFvuL0zZS3R9NUannhoSFJ1gf/JVPpmGXCGJK8YGMvrwg= ;
 
Dear all,
 
I want to add two vectors of unequal length such that the vectors in one are added to each of the values in the other, e.g.
 
a<- c(22, 40, 60, 81)
b <- c(3, 5, 9)
 
c<- c(a[1] +b, a[2]+b, a[3]+b, a[4]+b) 
 
Is there a shorthanded way to do
c(a[1] +b, a[2]+b, a[3]+b, a[4]+b)  ?
 
Thanks in advance.
 
Eric


Yahoo! Music Unlimited - Access over 1 million songs. Try it free.
<Prev in Thread] Current Thread [Next in Thread>