I have dataset where many variables are actually kind of "one hot encoded", and I would like to collapse it to have a single variable with the value.
name born_2017 born_2018 born_2019
<chr> <dbl> <dbl> <dbl>
1 Paul 0 1 0
2 Diane 0 0 1
3 Jose 1 0 0
And I want it to look like that :
name birth_year
<chr> <chr>
1 Paul born_2018
2 Diane born_2019
3 Jose born_2017
I watched around dplyr
and tidyr
but I somehow didn't find what I need.
ps: I have to do this for a lot of variables so an easily generalizable solution, or working with the pipe, would be very helpful