调用Plot函数列表时R中的语法错误

时间:2013-01-09 16:42:10

标签: r list plot syntax-error

我有一个列表,我想将内容放在绘图代码中,但我遇到了这个错误:

Error: object 'pl29' not found

此外,相应的代码是:

Pl29 <- list(HMn25_29,HMn28_29)
par(mfrow=c(2,2))
for ( i in pl29) {
  plot(i, type = "o", pch = 22, lty = 2, col = "Black", xlab = "Hour  2007/09/29" , ylab = "Ambient Tempreture")
}

样本数据是:

(HMn25_29)
                    h   avg_val
1 2007-09-29 00:00:00 -1.876667
2 2007-09-29 01:00:00 -1.693667
3 2007-09-29 02:00:00 -1.766667
4 2007-09-29 03:00:00 -1.928667
5 2007-09-29 04:00:00 -2.132581
6 2007-09-29 05:00:00 -1.752258

      (HMn28_29)
                    h   avg_val
1 2007-09-29 00:00:00 -1.922500
2 2007-09-29 01:00:00 -1.667667
3 2007-09-29 02:00:00 -1.582000
4 2007-09-29 03:00:00 -1.571667
5 2007-09-29 04:00:00 -1.829000
6 2007-09-29 05:00:00 -1.615333

1 个答案:

答案 0 :(得分:0)

R区分大小写,您忘记第二次将Pl29大写:

Pl29 <- list(HMn25_29,HMn28_29)  # capitalized: Pl29
par(mfrow=c(2,2))
for ( i in pl29)  # not capitalized: pl29