在R中按小时统计推文的绘图

在R中按小时统计推文的绘图,r,csv,twitter,plot,hour,R,Csv,Twitter,Plot,Hour,我在R中使用searchtwitter函数来提取推文。我还使用write.csv函数创建了一个csv,其中包含一个名为“created”的时间戳变量。这是我用来从timestamp变量中提取时间的代码: datetime<-strftime(tweets$created, "%Y-%m-%d %H:%M:$S") time<-strftime(datetime, format="%H:%M:%S") 以及: 最后, plot(time, count(text),xlab="Time

我在R中使用searchtwitter函数来提取推文。我还使用write.csv函数创建了一个csv,其中包含一个名为“created”的时间戳变量。这是我用来从timestamp变量中提取时间的代码:

datetime<-strftime(tweets$created, "%Y-%m-%d %H:%M:$S")
time<-strftime(datetime, format="%H:%M:%S")
以及:

最后,

plot(time, count(text),xlab="Time", ylab="No. of Tweets")

通过将
time
hour
变量放入
tweets
data.frame,可以简化此操作。您还应该看看
table
函数,它将允许您执行
table(tweets$hour)
绘图(table(tweets$hour)
,甚至
条形图(tweets$hour)
strftime的返回值只是一个字符串,因此您可以通过多种方式从
time
获取小时数..或者编写您自己的函数:
t@rawr-
lubridate::hour
是一个函数,至少在我当前的R版本中是这样。不管怎样,都需要附加lubridate。我想知道是否有数据表还没有找到解决办法吗
plot(count(time),xlab="Hour", ylab="No. of Tweets")
plot(time, count(text),xlab="Time", ylab="No. of Tweets")