Reverse the content order of several columns (ideally in tidyverse)
You can do the following:
pivot_longer(df, -a) %>%
  filter(!is.na(value)) %>%
  mutate(value=rev(value), .by=a) %>%
  pivot_wider(names_from = name, values_from = value)

Output:
      a     b     c     d
  <int> <dbl> <dbl> <dbl>
1     1     6     4     1
2     2     6     2    NA
3     3     6    NA    NA


Assuming the following data:
df <- data.frame(a = 1:3, b = c(1, 2, 6), c = c(4, 6, NA), d = c(6, NA, NA))

  a b  c  d
1 1 1  4  6
2 2 2  6 NA
3 3 6 NA NA

And what I want is:
  a b  c  d
1 1 6  4  1
2 2 6  2 NA
3 3 6 NA NA

I thought about some combination of across and rev, but my current attempts don't work.
