Here is a solution using reshape2's melt to get the fruits into a single column along with group, filtering out the relevant records only then using aggregate to get the information you are looking for:
#defining matrix of variables
mm <- matrix(0,10,3)
rownames(mm) <- rownames(mm, do.NULL = FALSE, prefix = "pID")
colnames(mm) <- c("orange", "mango","banana")
mm <- apply(mm, c(1,2), function(x) sample(c(0,1),1))
mm1 <- matrix(sample(seq(1,3),10,1))
colnames(mm1) <- c("group")
mm1
main <- cbind(mm,mm1)
main
main <- as.data.frame(main)
main$pid <- rownames(main)
rownames(main) <- NULL
main_molten <- reshape2::melt(main, id.vars = c("pid", "group"))
relevant <- main_molten[main_molten$value == 1, ]
aggregate(relevant$pid, by=list(relevant$group, relevant$variable), FUN=paste)