[R] help with if statement

anto.r anto.rajaa at gmail.com
Tue Dec 4 15:15:16 CET 2012


DT<-data.frame(time=c(0,1,5,24,36,48,72),DV=seq(0,60,10))
  time DV
1    0  0
2    1 10
3    5 20
4   48 30
5   84 40
6   96 50
7  120 60
You want to add 24 to values that are >=24 in 'time'

DT[DT$time>=24,'time']<-DT[DT$time>=24,'time']+24
  time DV
1    0  0
2    1 10
3    5 20
4   48 30
5   60 40
6   72 50
7   96 60

Is this what you were looking for?
A.




--
View this message in context: http://r.789695.n4.nabble.com/help-with-if-statement-tp4652015p4652055.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list