0

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"))
Yulia Kentieva
  • 433
  • 3
  • 10
  • 1
    Did you try just putting those lines as a function in lapply? What list do you plan to iterate over with the `lapply`? Are you stroing object names as character values? It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. Maybe something like `lapply(list_of_object_names, function(x) {obj_1 – MrFlick Apr 19 '22 at 15:53

0 Answers0