It's not exactly clear what you do want. Possibly
test <- c(1,5)[1+(1:25) %in% group1]
Same result as:
test <- ifelse( 1:25 %in% group1, 5, 1)
Oh, OK, i'll make the for
-loopy version, too:
test <- integer(25)
for (ii in 1:25){
if (ii %in% group1){test[ii] <- 5} else {test[ii] <- 1}
}
test