Juan Luis Herrera Cortijo
banner
jl-herrera-cortijo.bsky.social
Juan Luis Herrera Cortijo
@jl-herrera-cortijo.bsky.social
Of course, lambda functions should be used judiciously and better suited for simple, one-time computations.
December 3, 2024 at 8:13 AM
By choosing the appropriate .keep option, you can tailor your data frames to include only the necessary variables, making your analysis cleaner and more efficient! ✨
#RStats #DataScience #Programming
November 27, 2024 at 2:26 PM
[5/5] .keep = "none"
Keeps only the newly created variables.

df %>% mutate(new_var = x + y, .keep = "none")

Only new_var is retained. This option is great for isolating the results of your mutations.
November 27, 2024 at 2:26 PM
[4/5] .keep = "unused"
Keeps only variables not used in the mutation.

df %>% mutate(new_var = x + y, .keep = "unused")

All columns except x and y are kept, along with new_var. Useful when you want to exclude variables involved in the mutation.
November 27, 2024 at 2:26 PM
[3/5] .keep = "used"
Keeps only variables used in the mutation and the new ones.

df %>% mutate(new_var = x + y, .keep = "used")

Only x, y, and new_var are kept. Unused columns are dropped, reducing clutter!
November 27, 2024 at 2:26 PM
[2/5] .keep = "all" (Default)
Keeps all existing variables alongside the new ones.

df %>% mutate(new_var = x + y, .keep = "all")

All columns in df are retained, plus new_var. This is the default behavior.
November 27, 2024 at 2:26 PM
**[4/4]** By adjusting `.homonyms`, you can fine-tune how your functions handle duplicate argument names, making your code more robust and customizable. Handy for setting defaults that users can override! 🎯 #RStats #Programming
November 25, 2024 at 6:15 AM