【发布时间】:2021-05-06 22:39:05
【问题描述】:
我的数据如下所示:
> head(mydata, 24)
time exp2
1 Jan-99 24977.25
2 Feb-99 21186.07
3 Mar-99 41245.92
4 Apr-99 47.57
5 May-99 25254.42
6 Jun-99 164.95
7 Jul-99 9629.81
8 Aug-99 164.95
9 Sep-99 47091.12
10 Oct-99 0.09
11 Nov-99 3458.64
12 Dec-99 24.00
13 Jan-00 28636.17
14 Feb-00 23850.65
15 Mar-00 23680.16
16 Apr-00 513.82
17 May-00 252.17
18 Jun-00 178.10
19 Jul-00 20293.85
20 Aug-00 474.16
21 Sep-00 164.95
22 Oct-00 164.95
23 Nov-00 164.95
24 Dec-00 96.10
>
我想在 ggplot 中创建一个简单的图表,使用:
newdata2 <- mydata %>%
mutate(date = as.Date(time, format = "%m/%y"))
ggplot(newdata2, aes(x = time, y = exp2)) +
geom_line(color = "darkorchid4")
错误是:
geom_path: Each group consists of only one observation. Do you need to adjust
the group aesthetic?
运行时:
mydata$time <- as.Date(mydata$time, format = "%m/%y")
ggplot(mydata, aes(x = time, y = exp2)) +
geom_line(color = "darkorchid4")
我收到此错误:
Error in seq.int(0, to0 - from, by) : 'to' must be a finite number
我不明白为什么会出现这个错误。 你能帮帮我吗?
【问题讨论】:
-
你检查
newdata2的输出了吗?date列由什么组成?