Sorry guys if this is a noob question. I need help on how to loop over my dataframe.Here is a sample data.
a <- c(10:29); b <- c(40:59); e <- rep(1,
data.frame(a, b, e=(1:4)[cut(a, c(-Inf, 15, 20, 25, 30))])
Update:
Greg's comment provides a more direct solution without the need to go via subsetting an integer vector with a factor returned from cut.
cut
data.frame(a, b, e=findInterval(a, c(-Inf, 15, 20, 25, 30)))