Hello,

I have a data frame with hourly or sub-hourly weather records that span
several years, and from that data frame I'm trying to select only the
records taken closest to noon for each day. Here's what I've done so far:

#Add a column to the data frame showing the difference between noon and the
observation time (I converted time to a 0-1 scale so 0.5 represents noon):
data$Diff_from_noon <- abs(0.5-data$Time)

#Find the minimum value of "Diff_from_noon" for each Date:
aggregated <- aggregate(Diff_from_noon ~ Date, data, FUN=min)


The problem is that the "aggregated" data frame only has two columns: Date
and Diff_from_noon. I can't figure out how to get the columns with the
actual weather variables to carry over from the original data frame.

Any suggestions you have would be much appreciated.

Thanks,
Sean

	[[alternative HTML version deleted]]

