R中字符串向量的循环函数

问题描述 投票:0回答:1

我需要循环以下函数,以输出字符串向量中所有值的单独曲线图。这些值是三个字母的国家/地区代码,下面以单个坦桑尼亚("TZA")为例。国家代码的向量可以通过CountryList$Country

指定
 tiff("TZA_vanda.tiff", units="in", width=8, height= 6, res=120)
    tscsPlot(a.out2, cs = "TZA", var = "vanda")
    dev.off()
r loops plot
1个回答
0
投票

显然,未经测试,但也许符合这些原则?

for (i in unique(CountryList$Country)) {
  tiff(sprintf("%s_vanda.tiff", i), units="in", width=8, height= 6, res=120)
  tscsPlot(a.out2, cs = i, var = "vanda")
  dev.off()
}
© www.soinside.com 2019 - 2024. All rights reserved.