plot - Plotting time and date in different axis in R -
i have data looks
head(data1,10)
id time type value1 value2 value3 1 1612 7/1/2014 10:15 activity none 2 76308 7/1/2014 10:17 battery discharging 3 1613 7/1/2014 10:17 activity none 4 1614 7/1/2014 10:17 activity none 5 1615 7/1/2014 10:17 activity none 6 1616 7/1/2014 10:17 activity none 7 1617 7/1/2014 10:17 activity none 8 325200 7/1/2014 10:17 wifi linksys 00:1a:70:5b:8f:21 -86 9 1618 7/1/2014 10:19 activity none 10 1619 7/1/2014 10:19 activity none
the complete data can download in this link format data csv size around 1.6 mb. data has 5 important columns (time, type, value1, value2, value3). type contain : activity means user activity (none, high, low), sms, wifi, etc.
i want plot data this:
x axis time interval 1 hour , y axis date interval 1 day. , each type have different colour in figure.
when many value in same time plot more thick, , activity types want different colour (none, high, , low).
really, have no idea it, need help. thank you,
unsure how going use data plot, here assume plotting type against time value across different days. see if looking for:
# transforming data library(data.table); library(tidyr); library(ggplot2) test = fread("data_test.csv") # data file in working directory test = separate(test, time, c("days","time"), sep=" ") test$days = as.posixct(strptime(test$days, "%m/%d/%y")) test$time = as.posixct(strptime(test$time, "%h:%m")) # plot ggplot(test, aes(x=time, y=type, colour=type, shape=type)) + theme_bw() + geom_point() + facet_grid(days ~.) + scale_x_datetime(breaks=date_breaks("1 hour"), labels = date_format("%h:%m"))
Comments
Post a Comment