Re: [R] Assign value to a row in dataframe

2015-01-21 Thread zuzana zajkova
b > 12 290 2011-11-19 08:56:54 a b a > 13 291 2011-11-19 09:19:39 b a b > > > > which results in desired solution. > > Cheers > Petr > > > > -Original Message- > > From: R-help [mailto:r-help-boun...@r-proj

Re: [R] Assign value to a row in dataframe

2015-01-21 Thread PIKAL Petr
b > which results in desired solution. Cheers Petr > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of zuzana > zajkova > Sent: Tuesday, January 20, 2015 11:15 PM > To: r-help@r-project.org > Subject: [R] Assign value to a row in da

Re: [R] Assign value to a row in dataframe

2015-01-21 Thread zuzana zajkova
Hi Jim, your code works just perfectly, it is exactly what I was looking for, thank you very much!!! I'm glad to learn something new, I haven't seen the use of "drow in 1:(dim(all)[1])" before. I made the code a bit shorter, excluding the use of "stat_bef" column, which I created just for my inte

Re: [R] Assign value to a row in dataframe

2015-01-20 Thread Jim Lemon
Hi Zuzana, >From your description it seems that you want to repeat the last "state_new" value when there are repeated zeros in both "state" and "state_bef". If that is the case, you may need to step through the data frame like this: for(drow in 1:(dim(test)[1])) { if(test$state[drow] != 0) test$s

[R] Assign value to a row in dataframe

2015-01-20 Thread zuzana zajkova
Hi, I have probably basic question, but I would be happy if somebody could help me with this: I have a dataframe where I want to assign a value to other column copying the value in previous row under some condition. Here is an example (dput on the end of message): > test[278:290,]