[R] functions applied to two vectors

2007-10-23 Thread Anya Okhmatovskaia
Hi, I am very new to R, so I apologize if I have missed some trivial thing in the manuals/archives. I am trying to get rid of for loops in my code and replace them with R vector magic (with no success). Let's say I have 2 vectors of the same length: a - c(2, 3, 7, 5) b - c(4, 7, 8, 9) What I'd

Re: [R] functions applied to two vectors

2007-10-23 Thread Rolf Turner
On 24/10/2007, at 4:15 PM, Anya Okhmatovskaia wrote: Hi, I am very new to R, so I apologize if I have missed some trivial thing in the manuals/archives. I am trying to get rid of for loops in my code and replace them with R vector magic (with no success). Let's say I have 2 vectors

Re: [R] functions applied to two vectors

2007-10-23 Thread Tony Plate
a - c(2, 3, 7, 5) b - c(4, 7, 8, 9) mapply(seq, a, b) [[1]] [1] 2 3 4 [[2]] [1] 3 4 5 6 7 [[3]] [1] 7 8 [[4]] [1] 5 6 7 8 9 mapply(sum, a, b) [1] 6 10 15 14 hope this helps, Tony Plate Anya Okhmatovskaia wrote: Hi, I am very new to R, so I apologize if I have missed some

Re: [R] functions applied to two vectors

2007-10-23 Thread Christos Hatzis
] functions applied to two vectors On 24/10/2007, at 4:15 PM, Anya Okhmatovskaia wrote: Hi, I am very new to R, so I apologize if I have missed some trivial thing in the manuals/archives. I am trying to get rid of for loops in my code and replace them with R vector magic