[R] Hot Air Balloon Weather Briefings

Jim Lemon drj|m|emon @end|ng |rom gm@||@com
Sun Aug 16 00:41:15 CEST 2020


Hi Philip,
My fault for assuming that what worked for the sample data would work
for the entire data set. If you run the following code:

# read the file into a data frame
phdf<-read.csv("phdf.csv",stringsAsFactors=FALSE)
print(dim(phdf))
# create a logical variable for the subsetting step
keep<-rep(TRUE,length(phdf$Speed))
# this follows the conventional for(i in ...) syntax
# mini (minute index) is the name of the variable
# that is assigned the successive values of the
# unique values in the Minute column of phdf
# here I was lazy and only dealt with the sample data
# what I should have done was to create a column
# with minute values that don't repeat
phdf$hourmin<-phdf$Hour.Z * 60 + phdf$Minute
for(mini in unique(phdf$hourmin)) {
 # mark all minutes that are all zeros for deletion
 if(all(phdf$Speed[phdf$hourmin == mini] == 0))
  keep[phdf$hourmin == mini]<-FALSE
 # but now there is another condition
 # that I didn't notice (more laziness)
 # drop minutes containing ten consecutive zeros
 # I'll use a cheap trick for this
 # if the length of the run length encoding (rle)
 # of the Speed == 0 condition is less than three,
 # then there can't be a broken run of zeros
 if(length(rle(phdf$Speed[phdf$hourmin == mini])$length)<3)
  keep[phdf$hourmin == mini]<-FALSE
}
# now drop any rows for which has marked FALSE (note all caps!)
phdf<-phdf[keep,]
print(dim(phdf))

You will see that it has removed 67 rows. This is the same as if I had
only applied the first "all zeros"  condition, for there were no
unique minutes with 11 observations that contained a single non-zero
speed value. I can see that you are getting short runs of zero speeds
near the end. I assume that this is due to the balloon slowly bumping
along the ground. Often just looking at the data can suggest solutions
to problems like this.

Coincidentally I am about to email an old friend of mine whose sons
have dabbled in sending balloons high into the air and I will let them
know that they are not alone in performing this unusual practice. If I
haven't answered all your questions, feel free to let me know.

Jim

On Sun, Aug 16, 2020 at 4:39 AM Philip <herd_dog using cox.net> wrote:
>
> Thanks for getting back to me so quickly.
>
> I can get your code to run without errors but I'm not sure what it
> accomplishes since I still get 813 rows of data and 11 variables.  The
> entire file for a January flight is attached.  Also attached is a .jpg of a
> flight from a couple of years ago where my wife putzed back and forth across
> a road for over an hour by going up or down to catch different winds.  Stuff
> like this is one of the charms of the sport for those of us who are easily
> amused.
>
> keep <- rep(TRUE,length(phdf$Speed))             #813 repetitions of TRUE
> for(mini in unique(phdf$Minute))
>   if(all(phdf$Speed[phdf$Minute==mini]==0))
>   keep[phdf$Minute==mini]<-False                     #813 repetitions of
> TRUE in the keep data file.
>
> #Don't understand the assignment (<-) to FALSE
> phdf <- phdf[keep,] #Still have 813 rows of data.
>
> As you may know, we lay out the balloon and then blow cold air into the
> envelope with a gas powered fan.  When it is packed we "go hot".  Just
> before we turn on the pilot light and hit the burner we will turn on the
> tracking software which results in several minutes of no movement at the
> beginning of the flight.  This is what is happening between rows 2 and 70 of
> the attached spreadsheet.  You will also notice that the balloon slowly
> accelerates between rows 71 and 79 p to about 3.4 MPH just after liftoff.
> The no movement is what I want to eliminate.
>
> Can you let me know what I am missing.
>
> Two more thing.  I really not sure about the:
>
>     for(mini in unique(phdf$Minute))
>
> .....line of code.  I understand the unique function but not the "mini
> in..." part.  Is mini a function or just a label?   I understand stuff like:
>
>     for(i in 1:5) print(1:i)
>
> .....from the R base documentation but not real sure how it fits in here.
>
> And finally, I'm retired,  So I have plenty of time and determined to learn
> R.  But I keep running into things like the "mini in unique" command.  I
> have read four or five books and watched or read dozens of tutorials but
> there always seems to be another layer that alludes me.  Any suggestions?
>
> Philip



More information about the R-help mailing list