I am having a real hard time with ggplot function!
I try to briefly explain my problem.
I have a dataset of several tweets associated to a time stamp; I would like to plot the data obtaining a graph with time on the x bar and the frequency or the "tweet-rate" per hour on the y axis.
What did I do?
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")
So basically I truncated the data by the timestamp and used the count function to plot them.
I get the
Error: No layers in plot
and
Error in +geom_bar(stat = "identity") : argument not valid for the operator
But why? what am I doing wrong? I usually have this problem each time i try to plot something via ggplot, what do I do wrong?
Thank you! Vincenzo
+... or put parentheses around the whole expression to stop R interpreting theggplot()call before you get a chance to add geoms to it.