[R] count value changes in a column

2011-05-31 Thread Justin Haynes
is there a way to look for value changes in a column? set.seed(144) df-data.frame(state=sample(rep(1:5,200),1000)) any of the five states are acceptable. however if, for example, states 4 or 5 follow state 3, i want to overwrite them with 3. changes from 1 to any value and 2 to any value are

Re: [R] count value changes in a column [EDIT]

2011-05-31 Thread Justin
Justin Haynes jtor14 at gmail.com writes: is there a way to look for value changes in a column? df-data.frame(state=sample(rep(1:5,200),1000)) any of the five states are acceptable. however if, for example, states 4 or 5 follow state 3, i want to overwrite them with 3. changes from 1

Re: [R] count value changes in a column

2011-05-31 Thread jim holtman
Why isn't the sequence: 1 3 3 3 3 3 2 4 2 1 5 3 3 3 according to your rule about 5s following 3s. On Tue, May 31, 2011 at 6:23 PM, Justin Haynes jto...@gmail.com wrote: is there a way to look for value changes in a column? set.seed(144) df-data.frame(state=sample(rep(1:5,200),1000)) any

Re: [R] count value changes in a column

2011-05-31 Thread Bill.Venables
To: Justin Haynes Cc: r-help@r-project.org Subject: Re: [R] count value changes in a column Why isn't the sequence: 1 3 3 3 3 3 2 4 2 1 5 3 3 3 according to your rule about 5s following 3s. On Tue, May 31, 2011 at 6:23 PM, Justin Haynes jto...@gmail.com wrote: is there a way to look for value changes

Re: [R] count value changes in a column

2011-05-31 Thread Justin Haynes
I apologize for the confusion but that solution will work with a twist. I want to record only the first value of a state change that goes above 2. so if the sequence is 344455544334 it should read all 3s but 3442555414433 should read 33321 Hope that helps clarify, if not I can get