I have a dataset in data frame format, like this:
wpt ID Fuel Express Local
1 S36 12 0 1
2 S36 14 1 0
inter S36 NA 1 0
inter S36 NA 1 0
3 S36 16 1 0
inter S36 NA 0 0
4 S36 12 1 0
5 S36 12 1 0
I'd like to treat the subdata dat[c(2,inter,inter,3),] (any part with "inter" combined with regular numbered wpt)as a unit.
(1) count how many such sub-units in my data frame, in this case it has two (unit with row from 2 to 3, and 3 to 4)
(2) then count how many such units with Express or Local value of rows with "inter" different from either the starting or ending value of the sub-unit. In this case, it has 1 such unit consistent and 1 unit different from the starting or ending value of such units.
Thanks in advance!
Aucun commentaire:
Enregistrer un commentaire