In the code below, I use map from the purrr package to iterate over each column name, instead of a for loop. I've used the built-in mtcars data frame for illustration. We need the column names to name the files and select the columns for plotting, but we can get those on the fly with names(mtcars). We exclude the mpg column, because that one appears in every plot (we're using it as the equivalent of Angle in your example):
library(tidyverse)
map(names(mtcars)[names(mtcars) != "mpg"],
~ {
postscript(paste0(.x,".eps"))
plot(mtcars$mpg, mtcars[[.x]])
dev.off()
})
If you're more familiar with base R, the equivalent code using lapply would be:
lapply(names(mtcars)[names(mtcars) != "mpg"],
function(var) {
postscript(paste0(var,".eps"))
plot(mtcars$mpg, mtcars[[var]])
dev.off()
})