[R] Hot Air Balloon Weather Briefings

Philip herd_dog @end|ng |rom cox@net
Sat Aug 15 23:25:08 CEST 2020


Your suggestion worked like a charm.  Thank you

rle <- rle(TF$Speed)$lengths #Counts number of repetitions
phdf$rle <- rep(rle>9,rle) #TRUE is ten or more zeros.  FALSE if less than 10
phdf2 <- TF[rep(rle<10,rle),] #Move rows that are FALSE to new data file

From: Bert Gunter 
Sent: Friday, August 14, 2020 2:43 PM
To: Philip 
Cc: r-help 
Subject: Re: [R] 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.

> z <- rle(phdf$Speed)$lengths
## which gives:

> z
[1] 15  1  1  1  1  1  1  1  1  1
> rep(z>9,z)
[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:

> phdf[ rep(z<10, z), ]
   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 using cox.net> wrote:

  I’m trying to compare National Weather Service Rapid Update Forecast (RAP) data to GPS breadcrumbs collected by a really clever Apple Phone Ap that lays down longitude, latitude, altitude, compass direction, and speed every six seconds.   Below is a small subset of the GPS data from another flight.  

  I want to delete the rows where the balloon does not move (Speed column) for a full minute assuming that it is sitting on the ground – beginning of the flight, changing passengers, or waiting for the chase crew at the end of the flight.  for example, 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.  Any suggestions?  I’ve tried putzing around with multiple lags without success.

        Minute Second Speed 
        29 47 0 
        29 53 0 
        29 59 0 
        30 5 0 
        30 11 0 
        30 17 0 
        30 23 0 
        30 29 0 
        30 35 0 
        30 41 0 
        30 47 0 
        30 53 0 
        30 59 0 
        31 5 0 
        31 11 0 
        31 17 0.402649 
        31 23 0.671081 
        31 29 1.588225 
        31 35 2.438261 
        31 41 2.706693 
        31 47 2.930386 
        31 53 3.310666 
        31 59 3.198819 
        32 5 3.422512 


  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.

  Thanks,
  Philip Heinrich
          [[alternative HTML version deleted]]

  ______________________________________________
  R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.

	[[alternative HTML version deleted]]



More information about the R-help mailing list