r 我有一个这样的数据框:
dput(head(final,50))
structure(list(Date = structure(c(15779, 15780, 15781, 15782,
15783, 15784, 15785, 15786, 15787, 15788, 15789, 15790, 15791,
15792, 15793, 15794, 15795, 15796, 15797, 15798, 15799, 15800,
15801, 15802, 15803, 15804, 15805, 15806, 15807, 15808, 15809,
15810, 15811, 15812, 15813, 15814, 15815, 15816, 15817, 15818,
15819, 15820, 15821, 15822, 15823, 15824, 15825, 15826, 15827,
15828), class = "Date"), Pc = c(17.688, 10.824, 9.804, 11.136,
13.272, 12.42, 12.84, 15.156, 10.848, 9, 19.188, 12.84, 14.628,
16.104, 17.22, 10.716, 7.788, 16.488, 18.66, 14.904, 14.004,
16.08, 10.668, 9.024, 12.912, 11.364, 11.988, 11.316, 14.1, 9.96,
7.308, 13.044, 14.7, 12.636, 12.624, 15.696, 9.624, 8.124, 17.136,
13.428, 12.984, 13.14, 15.012, 10.5, 8.1, 11.964, 13.308, 12.972,
13.38, 14.556)), .Names = c("Date", "Pc"), row.names = c("1",
"6", "11", "16", "21", "26", "31", "36", "41", "46", "51", "56",
"61", "66", "71", "76", "81", "86", "91", "96", "101", "106",
"111", "116", "121", "126", "131", "136", "141", "146", "151",
"156", "161", "166", "171", "176", "181", "186", "191", "196",
"201", "206", "211", "216", "221", "226", "231", "236", "241",
"246"), class = "data.frame")
我需要创建一个 ggplot 我需要一些范围数据是不同的颜色。我试过这个:
ggplot() + geom_line(subset(final, Date < as.Date(c("2013-08-06"))), aes(Date, Pc, colour=blue, size=1)) + geom_line(subset(final, Date > as.Date(c("2013-08-05"))), aes(Date, Pc, colour=red, size=1.2))
我收到此错误:
Error: ggplot2 doesn't know how to deal with data of class uneval
可以在ggplot中做这样的事情吗?