ggplot - 错误:绘图中没有图层

时间:2013-12-29 23:33:28

标签: r ggplot2

ggplot功能真的很难!

我试着简要解释一下我的问题。

我有一个与时间戳相关的几条推文的数据集;我想绘制数据,以获得x条上的时间图和频率或y轴上每小时的“推文率”。

我做了什么?

library(ggplot2)
c4l.tweets <- read.csv("/Users/vincenzo/Desktop/Collect %23c4l13 Tweets - Archive.csv")
c4l.tweets$time <- as.POSIXct(strptime(c4l.tweets$time, "%d/%m/%Y %H:%M:%S", tz="CST") -       6*60*60)

library(chron)
c4l.tweets$by.hour <- trunc(c4l.tweets$time, units="hours")


ggplot(count(c4l.tweets, "by.hour"), aes(x=by.hour, y=freq))
+ geom_bar(stat="identity") + xlab("Number") + ylab("Date") + labs(title="tweets   by hour")

所以基本上我按时间戳截断数据并使用count函数绘制它们。

我得到了

 Error: No layers in plot

Error in +geom_bar(stat = "identity") : argument not valid for the operator

但为什么呢?我究竟做错了什么? 每次我尝试通过ggplot绘制一些东西时,我通常会遇到这个问题,我做错了什么?

谢谢! 蒙特拉

0 个答案:

没有答案