Hello, is there anyone who can show me how to write a function or loop that
cycles through a data frame and creates a new variable based on some
condition?  For example, suppose I want to create a variable called FYEAR
in a data frame conditional on the variable DATE, as follows:

DF$FYEAR[DF$DATE = as.Date('1992-06-30')] <- 1991;
DF$FYEAR[DF$DATE = as.Date('1993-06-30')] <- 1992;
DF$FYEAR[DF$DATE = as.Date('1994-06-30')] <- 1993;
DF$FYEAR[DF$DATE = as.Date('1995-06-30')] <- 1994;
DF$FYEAR[DF$DATE = as.Date('1996-06-30')] <- 1995;

and so on...

(PS this is just an example.  I know I can get the FYEAR straight from the
DATE.)

Is there any way to automate this using a for loop or something like that?
 Thank you!!  Geoff

	[[alternative HTML version deleted]]

