stevensanderson, The map() function applies a function across vectors, lists, or data frames efficiently. Syntax: map(.x, .f, ...) where .x is data, .f is function, ... for extra args. Examples: square vector elements via ~.x^2, get means of column across list of data frames with ~mean(.x$y), apply custom functions to rows/cols like df$z <- map_dbl(df, add_cols).
#R #RStats #RProgramming #Function #FunctionalProgramming #Functional #Programming #purrr #tidyverse
Post: https://www.spsanderson.com/steveondata/posts/2023-03-26/
Add comment