'Is there a way to mutate all columns at once [duplicate]

Is there a way to mutate all columns at once.

df <- structure(list(`Po` = list(c("2022-04-25","2022-04-25")), Por = list(
    c("522", "55")), `Be` = list(c("2022-04-25","2022-04-25")), 
    B = list(c("522", "43"))), row.names = "to_df", class = "data.frame")

new_df <-  df <- df %>% mutate(Por = sapply(Por, toString),
                        B = sapply(B, toString),
                        Po = sapply(Po, toString),
                        Be = sapply(Be, toString))

i am trying to mutate all columns individually. Can we not do it at once?

r


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source