This is my first question, so apologies if this isn't perfectly appropriate. A colleague of mine recently sent me a script where she loaded all of her packages using lapply, instead of repeated calls to library, e.g.
packages_list <- c("dplyr", "ggplot2")
lapply(packages_list, library, character.only = TRUE)
Instead, this is how I normally do it:
library(dplyr)
library(ggplot2)
Is using lapply computationally faster somehow? I can see how that for a script requiring large numbers of packages, using lapply might save me from repeatedly typing out library, but with auto-complete this doesn't seem like a huge benefit.
Most of the people in my faculty are beginners with R (we are biologists), and many of my students don't even know how apply works...I think using lapply at the beginning of the script is possibly confusing for complete novices. I'm just curious if you expert coders out there could provide more illuminating input. Thank you!