I have a dataframe with two columns(both are dates) and a million rows. I have to compare both the dates and return value in the third column. i.e if date in column A is greater than date in column B, return 1 in column C.
Thanks in advance :)
I have a dataframe with two columns(both are dates) and a million rows. I have to compare both the dates and return value in the third column. i.e if date in column A is greater than date in column B, return 1 in column C.
Thanks in advance :)
In
base
:In
dplyr
:Here are two ways you can try:
or
In second way, you can change to
dt[, C := 1][A <= B, C := 0]
by checking which has less obs.Maybe you need to provide a little reproducible example.