Idea steps:
1. Take the time data out from data.
2. Extract the date data from the time data.
3, according to date data to summarize the daily number of messages.
4, using Ggplot2 to draw.
#从data中获取时间信息time <-data$datetime# to extract the date attribute from the time p<-paste (year, Month (time), day, sep= "-") # Convert p to Data frame Timed<-data.frame (P) #通过P分组, p segment name becomes days, increment column Freq, GROUP by Quantity Fenzu<-sqldf ("Select P Days,count (*) Freq From Timed Group by P ") #上面fenzu后日期排序是混乱的, you need to sort the dates, from small to large #as.date () Convert the days column to a date #order () sort the dates from small to large fenzu<-fenzu[ Order (AS. Date (Fenzu$days)),] #利用ggplot开始作图 # data for the fenzu,x axis is the days,y axis for Freqggplot (Fenzu,aes (X=as). Date (days), y=freq) + #绘制密度图, fill down the color to medium purple, transparency to 0.5 Geom_area (fill= "Mediumpurple1", alpha=0.5) + #绘制顶点, The vertex is the? marker, the size is 3, the color is blue geom_point (shape= "?", size=3,colour= "blue") + #x坐标轴名称为时间, the y axis name is message density xlab ("time") + Ylab ("message density") + #设置图表的主题 theme_solarized_2 ()
Final Build:
R language Combat-how to analyze QQ Group Records 2-Daily Information Quantity chart