Skip to content

I think you misunderstood my explantation.

1 message · arun

#
Hi,
Sorry, I didn't check your codes previously.

I hope this works for you (especially the <0).
Using the first dataset temp:
temp$ACTIVE_KWH[!is.na(temp$ACTIVE_KWH)][c(FALSE,diff(temp$ACTIVE_KWH[!is.na(temp$ACTIVE_KWH)])< 0)]<-NA
temp$REACTIVE_KWH[!is.na(temp$REACTIVE_KWH)][c(FALSE,diff(temp$REACTIVE_KWH[!is.na(temp$REACTIVE_KWH)])< 0)]<-NA
temp
#????? ID??????? CTIME ACTIVE_KWH REACTIVE_KWH
#1? HM001 201212121301???? 1201.9?????? 1115.5
#2? HM001 201212121302???? 1202.2?????? 1115.8
#3? HM001 201212121303???? 1202.8?????? 1115.8
#4? HM001 201212121304???????? NA?????? 1116.1
#5? HM001 201212121305???? 1203.9?????? 1116.7
#6? HM001 201212121306???????? NA?????? 1116.7
#7? HM001 201212121307???????? NA?????? 1116.7
#8? HM001 201212121308???????? NA?????????? NA
#9? HM001 201212121309???? 1206.0?????? 1118.2
#10 HM001 201212121310???? 1206.3?????? 1118.6
#11 HM001 201212121311???? 1206.5?????? 1118.8
#12 HM001 201212121312???????? NA?????????? NA
#13 HM001 201212121313???? 1207.3?????????? NA
#14 HM001 201212121314???? 1207.9?????? 1121.1
#15 HM001 201212121315???? 1208.4?????? 1121.3
temp1$ACTIVE_KWH[!is.na(temp1$ACTIVE_KWH)][c(FALSE,diff(temp1$ACTIVE_KWH[!is.na(temp1$ACTIVE_KWH)])< 0)]<-NA

#Similarly with the second dataset:
temp1$ACTIVE_KWH[!is.na(temp1$ACTIVE_KWH)][c(FALSE,diff(temp1$ACTIVE_KWH[!is.na(temp1$ACTIVE_KWH)])< 0)]<-NA
temp1$REACTIVE_KWH[!is.na(temp1$REACTIVE_KWH)][c(FALSE,diff(temp1$REACTIVE_KWH[!is.na(temp1$REACTIVE_KWH)])< 0)]<-NA


A.K.