search for: makegroup

Displaying 1 result from an estimated 1 matches for "makegroup".

Did you mean: make_group
2012 May 08
1
grouping function
...n 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 condit...