我目前有一些像下面这样的表格,我想用ggplot2()绘制时间(作为x轴)和Ask(作为y轴),
> data
Time Ask Bid Ask_Vol Bid_Vol
1 2013.03.01 00:05:01.469 1.30600 1.30608 1.50 2.25
2 2013.03.01 00:05:04.329 1.30600 1.30607 1.50 1.50
3 2013.03.01 00:05:05.499 1.30600 1.30607 1.50 1.50
4 2013.03.01 00:05:07.320 1.30598 1.30607 1.73 6.38
5 2013.03.01 00:05:07.909 1.30598 1.30606 1.73 2.25
6 2013.03.01 00:05:08.820 1.30598 1.30605 1.73 1.50
7 2013.03.01 00:05:09.011 1.30597 1.30602 1.73 1.50
8 2013.03.01 00:05:09.250 1.30594 1.30600 1.50 2.25
9 2013.03.01 00:05:09.310 1.30593 1.30600 1.73 2.25
10 2013.03.01 00:05:09.991 1.30592 1.30599 2.10 1.50
我试过了
ggplot(data, aes(Time, Ask)) + geom_line())
它给了我一张空图表和一条消息,我不知道这是什么。第一次使用R,我是新手,感谢您的帮助
geom_path: Each group consist of only one observation. Do you need to adjust the group aesthetic?
答案 0 :(得分:1)
不确定您想要什么类型的X轴标签,但这可以帮助您入门。
library(ggplot2)
# Convert time to proper class
data$Time <- as.POSIXct(data$Time, format="%Y.%m.%d %H:%M:%OS")
# Plot using the basic qplot function
qplot(Time, Ask, data = data) + geom_line()