#'@title a lapply that unlists!
#'@description run a function over a list or vector, as lapply does,
#'but unlist the results before returning them - a common operation.
#'
#'@param x a vector or list.
#'
#'@param fun the function to apply.
#'
#'@param unname whether or not to also unname the result. Set to
#'TRUE by default.
#'
#'@param ... further arguments to pass to \code{fun}
#'
#'@export
unlapply <- function(x, fun, unname = TRUE, ...){
result <- unlist(lapply(x,fun,...))
if(unname){
return(unname(result))
}
return(result)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.