Chris Dobkowski
Chris Dobkowski

Reputation: 325

Altering the data on diagrams

I am working on a statistics project and i came across one tiny issue. I have to work out a tactic for bidding on horse racing. We were given a set of 300 races with data such as the time, favorable odds, and if the favorable won or not. So i thought I could order the table in ascending order in relation to the time, and see how are the wins spread during the day. So I had games starting from 13:35 to 21:20, so I divided the time into 1 hour chunks (except the 1st chunk which is only 25 min, and last chunk which is only 20 min) and related wins to those chunks respectively. Then I added up all the wins inside each chunk, and presented that on the chart, the chart looks like this:

enter image description here

It works with my tactic which is to play between 14:00 and 16:00 cause then the bookie starts making odds as favorable to himself and starts robbing you from your earned money he just gave you. The thing is that on the bottom it says 2, 4, 6, 8.. but I want to write 13:35-14:00, 14:00 - 15:00 etc.. How can I do that, given that the code I used is that:

> plot(chunksVector, type="o", col="blue", xlab="Time", ylab="Wins")

How can I do this? I've been struggling with this one for some time now. Is there any way to alter the code?

P.S: "chunks" is just the name i gave to separated wins based on 1 hour distance. So i basically have a chink13.35_14.00, chunk14.00_15.00, chunk15.00_16.00 etc.. What I want to alter is only the X axis.

I want it to look like this:

enter image description here

Upvotes: 0

Views: 54

Answers (2)

zx8754
zx8754

Reputation: 56044

Instead of messing about with x labels, convert x to factor:

df <- data.frame(x=factor(c('14:00', '16:00', '18:00', '20:00')),
                 y=c(1,2,3,4))
plot(df)

Upvotes: 0

Stephen Henderson
Stephen Henderson

Reputation: 6522

the quick answer is:

plot(chunksVector, type="o", col="blue", xlab="Time", ylab="Wins", xaxt="n")

axis(1, at=c(2,4,6,8), labels=c('14:00', '16:00', '18:00', '20:00'))

There are probably a few other ways messing about with time-series packages?

Upvotes: 1

Related Questions