Re: [R] DPLYR Multiple Mutate Statements On Same DataFrame

2024-10-19 Thread Hadley Wickham
Out of interest, I asked chatGPT to take the original code, convert it to tidyverse style, use the base pipe, and collapse to a single mutate (interestingly I didn't need to explicitly ask to use across() and case_when), and I got code pretty similar to yours: df3 <- df0 |> mutate( across(st

Re: [R] DPLYR Multiple Mutate Statements On Same DataFrame

2024-10-18 Thread Rui Barradas
Às 08:27 de 18/10/2024, Rui Barradas escreveu: Às 22:50 de 17/10/2024, Sparks, John escreveu: Hi R Helpers, I have been looking for an example of how to execute different dplyr mutate statements on the same dataframe in a single step.  I show how to do what I want to do by going from df0 to d

Re: [R] DPLYR Multiple Mutate Statements On Same DataFrame

2024-10-18 Thread Rui Barradas
Às 22:50 de 17/10/2024, Sparks, John escreveu: Hi R Helpers, I have been looking for an example of how to execute different dplyr mutate statements on the same dataframe in a single step. I show how to do what I want to do by going from df0 to df1 to df2 to df3 by applying a mutate statement

Re: [R] DPLYR Multiple Mutate Statements On Same DataFrame

2024-10-17 Thread CALUM POLWART
Why can't you do: df0 |> mutate( ... ) |> mutate( ... ) |> mutate( ... ) I've simplified the code to show passing the result of the first line to the next rather than focussing on the detail. This would work with %>% as well as |> but I am anticipating that the more modern native pipe ( |> )

[R] DPLYR Multiple Mutate Statements On Same DataFrame

2024-10-17 Thread Sparks, John
Hi R Helpers, I have been looking for an example of how to execute different dplyr mutate statements on the same dataframe in a single step. I show how to do what I want to do by going from df0 to df1 to df2 to df3 by applying a mutate statement to each dataframe in sequence, but I would like