Write.csv(df, paste0('test', i, '.csv'), row.names = FALSE)
That way you don't have to create three separate variables in your global environment when there is no need to do so.Īs we don't have access to your data I need to set up some test data for a reproducible example: df = read.table(text = It is simpler if you don't use a for loop but instead use one of the *apply functions to generate a list with all three files within it.