首页 > 解决方案 > 循环 df 列表并打印文件地址

问题描述

我正在尝试循环输入数据框列表(几乎 30 df)并使用数据框的名称打印文件地址。例如:

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

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

另一种可能的解决方案:

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

但是,两者都给了我这个结果:

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

预期的输出是这样的:

[1] "C:/ME/Plots/ASE.png "
[1] "C:/ME/Plots/FES.png "
[1] "C:/ME/Plots/GAN.png "
[1] "C:/ME/Plots/PEC.png "

标签: r

解决方案


推荐阅读