Compare values of two columns?

Is there a way to compare two columns of a data frame to know which of those are equals?

Try this code. This is for a data frame with two columns A and B and their values are being compared.

df <- data.frame(A_points=c(1, 3, 3, 3, 5),
                 B_points=c(4, 5, 2, 3, 2))
df$winner <- ifelse(df$A_points == df$B_points, 'equal', "not equal")

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.