这是我的数据
time dprice
2018-03-05 09:00:00 113.34000
2018-03-05 09:05:00 0.00000
2018-03-05 09:10:00 98.47778
2018-03-05 09:15:00 127.85833
2018-03-05 09:20:00 42.33333
我想将非线性线绘制到该数据中,我的代码是:
library(ggplot2)
ggplot(df1_all, aes(df1_all$Time, df1_all$dprice)) +
geom_point() +
geom_smooth()
,结果如下:
没有非线性趋势线
答案 0 :(得分:0)
假设输入在末尾的注解中可重复显示,则生成一个图形:
library(ggplot2)
ggplot(df1_all, aes(time, dprice)) +
geom_point() +
geom_smooth()
或者尝试这种方式:
library(ggplot2)
library(zoo)
z <- read.zoo(df1_all)
autoplot(z) +
geom_smooth()
假定输入为可复制形式。请注意,time
被假定为POSIXct。
Lines <- "time,dprice
2018-03-05 09:00:00,113.34000
2018-03-05 09:05:00,0.00000
2018-03-05 09:10:00,98.47778
2018-03-05 09:15:00,127.85833
2018-03-05 09:20:00,42.33333"
df1_all <- read.csv(text = Lines)
df1_all$time <- as.POSIXct(df1_all$time)