I have a data set like below and i want to swap if a value in one variable is greater than the other.
data
start_year end_year
1991 1995
1994 1990
1997 1999
1994 1995
1995 1995
1996 1991
I want to swap the rows where start_year is greater than end_year.
Expected output:
start_year end_year
1991 1995
1990 1994
1997 1999
1994 1995
1995 1995
1991 1996
Tried:
data_created = if(data$start_year > data$end_year, data$start_year == data$end_year &
data$end_year == data$start_year, data$start_year == data$start_year &
data$end_year == data$end_year)
Please help me in this way.