Re: [R] Odp: Vector replace 0 elements without using a loop

2010-10-08 Thread rivercode
Petr and Bill, Thanks for your replies. I have gone with Petr use of na.locf(), but expect I can use Bill's full function in the near future. Chris -- View this message in context: http://r.789695.n4.nabble.com/Vector-replace-0-elements-without-using-a-loop-tp2966191p2968909.html Sent from

[R] Odp: Vector replace 0 elements without using a loop

2010-10-07 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 07.10.2010 07:16:01: Hi, With a vector like: x = c (22, 23, 22.5, 0,0,24, 0, 23.2, 23.5, 0,0,0, 26) How can I replace the 0's with the previous last value without looping through the vector ? Change your zeroes to NA values x[x==0]-NA

Re: [R] Odp: Vector replace 0 elements without using a loop

2010-10-07 Thread William Dunlap
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Petr PIKAL Sent: Thursday, October 07, 2010 12:13 AM To: rivercode Cc: r-help@r-project.org Subject: [R] Odp: Vector replace 0 elements without using a loop Hi r-help