I want to use skim inside a function. The function accepts a string vector which identifies which columns to skim. Example:
library(skimr)
n <- 10
foo <- data.frame(pin = rnorm(n), deltap = rgamma(n, 1), t = runif(n), name = letters[1:n])
selected_columns <- c("pin", "deltap")
I want to apply skim to pin and pout only, but their names are passed as strings. How can I solve this? This is an example of the function I’d like to use:
You might also consider writing your function to pass along a ... argument, which would then play nicely with all of dplyr’s select helpers (which we support).
@michaelquinn32 this is even better! I prefer passing a my_skim function to the function my_fun which has to use it, rather than modifying my calling function to pass a “reduced” dataframe to skim, because I then pass my_fun to sapply and apply it to a list of files…I would select your answer as “closed”, but I cannot see a tick-box below your answer.