Hello, I would like to write a function that makes a grouping variable for
some panel data .  The grouping variable is made conditional on the begin
year and the end year.  Here is the code I have written so far.

name <- c(rep('Frank',5), rep('Tony',5), rep('Edward',5));
begin <- c(seq(1990,1994), seq(1991,1995), seq(1992,1996));
end <- c(seq(1995,1999), seq(1995,1999), seq(1996,2000));

df <- data.frame(name, begin, end);
df;

#This is the part I am stuck on;

makegroup <- function(x,y) {
 group <- 0
 if (x <= 1990 & y > 1990) {group==1}
 if (x <= 1991 & y > 1991) {group==2}
 if (x <= 1992 & y > 1992) {group==3}
 return(x,y)
}

makegroup(df$begin,df$end);

#I am looking for output where each observation belongs to a group
conditional on the begin year and end year.  I would also like to use a for
loop for programming accuracy as well;

Thank you!  Geoff

	[[alternative HTML version deleted]]

