plot - R: time series with value -
i have log file dates , sizes (of files). plot bandwidth used per 1 min , per 5 minutes. input looks this:
2014-08-08 06:37:34.610 639205638 2014-08-08 06:37:37.110 239205638 2014-08-08 06:38:58.810 635899318 2014-08-08 06:38:21.877 1420094614 2014-08-08 06:40:11.772 140034211
so need bin values date 1 min , 5 minutes bins, sum each bin, average them number of minites, , plot them against time.
but have feeling has been done before , can utilize generic plotting function.
you can xts.
# read in info x <- read.table(text="2014-08-08 06:37:34.610 639205638 2014-08-08 06:37:37.110 239205638 2014-08-08 06:38:58.810 635899318 2014-08-08 06:38:21.877 1420094614 2014-08-08 06:40:11.772 140034211", stringsasfactors=false) # convert xts xx <- xts(x[, 3], as.posixct(paste(x[,1], x[, 2]))) # find 1 min , 5 min endpoints ep1 <- endpoints(xx, "minutes", 1) ep5 <- endpoints(xx, "minutes", 5) period.sum(xx, ep1) # 1 min sums period.sum(xx, ep5) # 5 min sums
more general (but slower):
period.apply(xx, ep1, sum)
for lastly part of question, take mean of these results
mean(period.sum(xx, ep1)) #[1] 1024813140
r plot
No comments:
Post a Comment