Skip to content

Comparing dates in dataframes

5 messages · James Rome, David Winsemius

#
My guess (since we still have no data on which to test these ideas)   
is that you need either to merge() or to use a matrix created from the  
dates and qtr-hours entries in "gw", since matching on dates and hours  
separately will not uniquely classify the good qtr-hours within their  
proper corresponding dates. You want a structure (or a matching  
process) that takes:
	hqhr1	qhr2	qhr3	qhr4 .......
date1	good	bad	good	bad
date2	bad	good	good	good
date3	bad	bad	bad	good
.
.
.
and lets you use the values in "arr" to get values in "gw". Notice  
that the notion of arr$Date %in% gw$date & arr$qtrhr %in% gw$qtrhr  
simply will not accomplish anything correct/

Merging by multiple criteria (with the merge function) would do that  
or you could construct a matrix whose entries were the categories  
good /bad. The table function could create the matrix for the purpose  
of using an indexed solution if you are dead-set against the merge  
concept.
On Jan 17, 2010, at 4:47 PM, James Rome wrote:

            
David Winsemius, MD
Heritage Laboratories
West Hartford, CT
#
Here are some sample data sets.

I also tried making a combined field in each set such as
adq=paste(as.character(arr$Date), as.character(arr$quarter))
and similarly for the weather set, so I have unique single things to
compare, but that did not seem to help much.

Thanks,
Jim
On 1/17/10 5:50 PM, David Winsemius wrote:
#
But, but, but .... there is no weather goodness variable in  
weather?!?!?!

 > str(weather)
'data.frame':	155 obs. of  4 variables:
  $ Date   :Class 'Date'  num [1:155] 14245 14245 14245 14245 14245 ...
  $ minute : int  5 15 30 45 0 15 30 45 0 15 ...
  $ hour   : int  15 15 15 15 17 17 17 17 18 18 ...
  $ quarter: int  65 75 90 105 68 83 98 113 72 87 ..

I thought you said the "weather" dataframe would have some information  
about "goodness" that we were supposed to map to arrivals.? What is  
the meaning of those variables? How do we define a "good" quarter  
hour? And why are the values of quarter not 1, 2, 3, 4? They ought to  
be a factor or integer that could be matched to those that are in  
"arr", which are also apparently not so defined. Let's see a better  
codebook or description of these variables.
On Jan 17, 2010, at 6:47 PM, James Rome wrote:

            
David Winsemius, MD
Heritage Laboratories
West Hartford, CT
#
Any entry in the weather data is a good day. That is the point. And
please ignore my mistake about the quarters getting too large in
weather. I am being swamped with versions, and it does not matter for
this purpose.. so, the bad weather days are not in the weather data set.

I am trying to get gw=1 in arr if the date and quarter are in weather.

Thanks,
Jim
On 1/17/10 7:46 PM, David Winsemius wrote: