Considering Titanic data set, I created several predictions on the survival and I want to create the final Survival based on a vote system, meaning that if the majority of the predictions stipulate that the passenger survived the final outcome is 1, 0 otherwise
> str(temp)
'data.frame': 179 obs. of 3 variables:
$ predictions_ldm : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
$ predictions_qda : Factor w/ 2 levels "0","1": 1 1 1 1 2 1 1 1 1 1 ...
$ predictions_glm_age: Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
> temp[c(4,5,12),]
predictions_ldm predictions_qda predictions_glm_age
4 0 0 0
5 0 1 0
12 1 1 0
I want the result to be
> temp[c(4,5,12),]
predictions_ldm predictions_qda predictions_glm_age Survived
4 0 0 0 0
5 0 1 0 0
12 1 1 0 1
How can I achieve this?