RStudio - loop command for series of images and export without overwriting

Hello!
I am quite new to R, so it might be a naive question.
For the analysis of a single image I have to enter a series of commands producing 2 different datasets (one is a data.frame, the other has to be converted as such) and, from these, two further graphs.
These commands have to be looped through the remaining images of the series I have, but the files of the latest image being processed (two Excel files and two pdf files) always overwrite those of the previous one. Could anyone kindly give me a hint on how to avoid this?

What have you tried so far ?

Could you ask this with a minimal REPRoducible EXample (reprex)? A reprex makes it much easier for others to understand your issue and figure out how to help.

In the end I chose to produce just files with each sheet named after each image (one per iteration) with as.character(). Using the "xlsx" package it is possible to append sheets over and over. I post this in case it comes useful to anyone.
@cderv thanks anyway for replying back!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.