ave base R
df1$new <- with(df1, ave(V2, V1, FUN = any))
df1$new
table
as.integer(rowSums(table(df1[1:2])!=0)==2)[df1$V1]
data.table
library(data.table)
setDT(df1)[, new := as.integer(any(V2)), by = V1]
df1
df1 <- structure(list(V1 = c(1L, 1L, 1L, 2L, 2L, 2L, 3L, 3L, 3L), V2 = c(0L,
0L, 0L, 1L, 1L, 0L, 0L, 0L, 1L), V3 = c(1234L, 1235L, 5434L,
31212L, 3212L, 1211L, 2212L, 2212L, 1212L)), .Names = c("V1",
"V2", "V3"), class = "data.frame", row.names = c(NA, -9L))