0

I'm trying to loop in a list of dataframes (almost 30 df) and print the file address with the name of the dataframe. For example:

q <- list(ASE, FES, GAN, PEC)
t <- "C:/ME/Plots/"

for (i in q){
  print(paste0(t,quote(i), ".png",sep=" "))
}

Another possible solution:

for (i in q){
  print(paste0(t, deparse(substitute(i)), ".png"))
}

However, both gives me this result:

[1] "C:/ME/Plots/i.png "
[1] "C:/ME/Plots/i.png "
[1] "C:/ME/Plots/i.png "
[1] "C:/ME/Plots/i.png "

The expected output is this:

[1] "C:/ME/Plots/ASE.png "
[1] "C:/ME/Plots/FES.png "
[1] "C:/ME/Plots/GAN.png "
[1] "C:/ME/Plots/PEC.png "
Chris
  • 1,502
  • 3
  • 15
  • 35
  • 3
    I encourage you to [read the documentation](https://stat.ethz.ch/R-manual/R-devel/library/base/html/substitute.html) for the `substitute` and `quote` functions to understand why they don’t work here. In addition, since the documentation may be a bit too terse, Hadley’s *Advanced R* has a [chapter](http://adv-r.had.co.nz/Expressions.html) on the topic. – Konrad Rudolph Jan 21 '19 at 15:00
  • Why not using the @Ronak Shah solution in the comment, in this way `paste0(t, names(q), ".png")` ? – s__ Jan 21 '19 at 15:07

0 Answers0