Build Graph(Plot) in R: median prices through time intervals -


i have data frame prices , ending date of auctions. want check when appears, example, sales minimal , maximal prices (also median) depending on time of day.

more precisely, have data frame mtest:

> str(mtest) 'data.frame':   9144 obs. of  2 variables: $ price      : num  178 188 228 305 202 ... $ enddatetime: posixct, format: "2015-05-25 05:00:59" "2015-05-23 00:06:01"  ... 

i want build graph(plot), having 30 minutes time internals (00:00-00:30, 00:31-01:00 etc) on x axis, , median (maximal, minimal prices) on y axis.
idea draw simple histogram each time interval, hist(mtest$price, breaks=10, col="red")

how can in best way?

try this:

cutt=seq(from=min(mtest$enddatetime),to=max(mtest$enddatetime), by=30*60) if (max(mtest$enddatetime)>max(cutt))cutt[length(cutt)+1]=max(cutt)+30*60 mtest$tint=cut(mtest$enddatetime,cutt) stats=do.call(rbind,tapply(mtest[,"price"],mtest[,"tint"],                      function(p)c(min=min(p),median=median(p),max=max(p)))) bp=boxplot(mtest[,"price"]~mtest[,"tint"],xaxt="n",            col=1:length(levels(mtest$tint))) axis(1,at=1:length(levels(mtest$tint)),labels=format.date(levels(mtest$tint),"%y-%m-%d %h:%m"),      las=2,cex.axis=.5) stats 

or wilth plot

plot(na,ylim=range(stats),xlim=c(1,lint),type="n",xaxt="n",xlab="",ylab="") sapply(1:3,function(z)points(stats[,z]~c(1:lint),col=z)) axis(1,at=1:lint,labels=format.date(levels(mtest$tint),"%y-%m-%d %h:%m"),      las=2,cex.axis=.5) 

you have this: enter image description here enter image description here


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -