On 1/17/10 1:06 PM, David Winsemius wrote:
>
> On Jan 17, 2010, at 12:37 PM, James Rome wrote:
>
>> I don't think it is that simple because it is not a one-to-one match. In
>> the arr data frame, there are many arrivals in a quarter hour with good
>> weather on a given day. So I need to match the date and the quarter
>> hour.
>>
>> And all of the rows in the weather data frame are times with good
>> weather--unique date + quarter hour. That is why I needed the loop. For
>> each date and quarter hour in weather, I want to mark all the entries
>> with the corresponding date and weather as TRUE in the arr$gw column.
>>
>> I did convert the dates to POSIXlt dates and rewrote my function as
>> gooddates = function(all, good) {
>>   la = length(all)   # All the arrivals
>>  lw = length(good)  # The good 15-minute periods
>>  for(j in 1:lw) {
>>    d=good$Date[j]
>>    q=good$quarter[j]
>>    all$gw[all$Date==d && all$quarter==q]=TRUE
>
>
> You are attempting a vectorized test and assignment with "&&" which
> seems unlikely to succeed, but even then I am not sure your problems
> would be over. (I'm also guessing that you might not have reported a
> warning.)

Why shouldn't the && succeed? You are correct there, because I do get
items if I use either part of this and test, when I insert the &&, I get
no hits. And I got no warnings.
>
> Why not merge arr to gw by date and quarter?
The sets contain different data, and the only thing I want from the
weather set is the fact that it has an entry for a given date and time
>
> Answering these questions would be greatly speeded up with a small
> sample dataset. Are you aware of the virtues of the dput function?
>

What I want is for a 1 to be in the gw column in the quarter
60,61,62,63,...

For example, here is some data from the good weather set:
Date    minute  hour    quarter         Efficiency Val
1/1/09  5       15      60      
1/1/09  15      15      61      72
1/1/09  30      15      62      63.3
1/1/09  45      15      63      85.4



And this is from the arrivals set:
DateTime        weekday         month   quarter         ICAO    Flight  gw

1/1/09  5       1       59      COA     COA349          0
1/1/09  5       1       59      NWA     NWA9934         0
1/1/09  5       1       60      JBU     JBU554          0
1/1/09  5       1       60      BTA     BTA2347         0
1/1/09  5       1       60      COA     COA886          0
1/1/09  5       1       60      BTA     BTA2916         0
1/1/09  5       1       60      CJC     CJC3225         0
1/1/09  5       1       60      BTA     BTA2085         0
1/1/09  5       1       60      BTA     BTA2064         0
1/1/09  5       1       60      AAL     AAL842          0
1/1/09  5       1       60      BTA     BTA1234         0
1/1/09  5       1       60      CJC     CJC3359         0
1/1/09  5       1       60      BTA     BTA3072         0
1/1/09  5       1       61      BTA     BTA3086         0
1/1/09  5       1       61      COA     COA1166         0
1/1/09  5       1       61      COA     COA855          0
1/1/09  5       1       61      AWE     AWE307          0
1/1/09  5       1       66      CHQ     CHQ5312         0
1/1/09  5       1       67      BTA     BTA2405         0



        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
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.

Reply via email to