Skip to content
Prev 385252 / 398503 Next

Hot Air Balloon Weather Briefings

Well which is it?:
"I want to eliminate the data for minute 30 but keep the data for minute 31
because the balloon starts to move again at second 17. "
or
"It would be even better if I could delete the rows where there were ten
consecutive zero speed entries such as from minute 30 second 17 to minute
31 second 11."

If you want to delete say data with >= 10 consecutive 0's, ?rle is your
friend:

rle(phdf$Speed)
Run Length Encoding
  lengths: int [1:10] 15 1 1 1 1 1 1 1 1 1
  values : num [1:10] 0 0.402649 0.671081 1.588225 2.438261 2.706693
2.930386 3.310666 3.198819 3.422512

e.g.
## which gives:
[1] 15  1  1  1  1  1  1  1  1  1
[1]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE
[11]  TRUE  TRUE  TRUE  TRUE  TRUE FALSE FALSE FALSE FALSE FALSE
[21] FALSE FALSE FALSE FALSE

##Thus:
Minute Second    Speed
16     31     17 0.402649
17     31     23 0.671081
18     31     29 1.588225
19     31     35 2.438261
20     31     41 2.706693
21     31     47 2.930386
22     31     53 3.310666
23     31     59 3.198819
24     32      5 3.422512

But of course, this probably isn't what you meant. So further clarification
is needed.

Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
On Fri, Aug 14, 2020 at 1:59 PM Philip <herd_dog at cox.net> wrote: