'how to save each object output of lapply() as a separate rds file?

How to save each object output of lapply(list_of_object_names, function_1)?

My function_1 takes a name of an existing object as input and gives a new object as an output. I need to use saveRDS(), but not sure how to combine with lapply.

I usually save objects one by one like this:

obj_1 <- function_1(object1_name)
saveRDS(obj_1, paste0("path_to_file/",object1_name, ".rds"))
r


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source