s-news
[Top] [All Lists]

Logic problem

To: <s-news@lists.biostat.wustl.edu>
Subject: Logic problem
From: "Lambert.Winnie" <lambert.winifred@ensco.com>
Date: Mon, 18 Feb 2002 11:20:47 -0500
Thread-index: AcG4mDk41C6zkge9RtOshxUg1v3lBw==
Thread-topic: Logic problem
S-PLUS 6 v2 on Windows XP

I have a dataframe created through tapply that has years, months, and days.  
February poses a problem since sometimes there are 29 days.  Thus the Day 
dimension in the resulting table is 29, resulting in 29 days for every year 
(1995 - 2001) in the dataframe.  I want to keep all the data from the Feb 29s 
in leap years, but eliminate the rows for Feb 29 in non-leap years.  I am 
trying to eliminate the extraneous 29's through the use of a logical, but am 
having no luck.  Year and Day are numerics, here are examples of things I have 
tried:

good <- if (year %% 4 != 0) {day <= 28]}
If (year %% 4 != 0) {good <- day <= 28}  both of these output F's for all 
29th's including leap years

good <- day[year %%4 != 0] <= 28  This eliminates 1996 and 2000 which I need to 
keep in the frame

What I want is a good that has T's for days that exist in the real world and 
F's for days that don't.  This seemed like such a simple issue when I 
started...any ideas?

***********************************************************************
Winifred C. Lambert                Senior Scientist/Meteorologist
ENSCO, Inc.
Aerospace Sciences and Engineering Division
1980 N. Atlantic Ave, Suite 230
Cocoa Beach, FL  32931
VOICE: 321.853.8130  FAX: 321.853.8415
lambert.winifred@ensco.com

AMU Quarterly Reports are available online:
http://science.ksc.nasa.gov/amu/home.html
***********************************************************************

<Prev in Thread] Current Thread [Next in Thread>
  • Logic problem, Lambert.Winnie <=