ifelse unused argument?

I create a data frame, and then run the ifelse function to add up and compare the columns of numeric info, while printing two different outcomes. Note I am loading readr and dplyr libraries.

I keep getting an 'Error in ifelse(., DT$A + DT$B > DT$C, print("1"), print("0")) : unused argument (print("0"))' in the following ...

library(readr)
library(dplyr)

DT <- data.frame(A=1:5, B=1:5*10, C=1:5*100)
DT

DT
A B C
1 1 10 100
2 2 20 200
3 3 30 300
4 4 40 400
5 5 50 500

DT %>%
ifelse(DT$A + DT$B > DT$C, print("1"), print("0"))

I suspect my grammar is the problem? I'm very much an R newbie.

Thanks!

You don't want the pipe. Internally, a pipe creates a first argument for a function and you've already specified all the arguments.

1 Like

This topic was automatically closed 7 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.