I am very new to using r and to programming itself. My major is nutrition. However, I recently started to code in r for my research. I am having trouble in formatting the x-axis for a graph and have searched a lot of forums for answers. I am not sure if I used the right terms to get the answer. Any help or link to the answer is appreciated.
My data consists of wheel counts that has been acquired every 5 minutes for a duration of two weeks. Accordingly, I am looking to label my X-axis to contain:
- dates as day 1, day 2, day 3, ........ day 4 as major labels.
- time as hours of day between two days as minor labels. This means that between two days, I need minor ticks representing the hours of the day.
- I want to add a background to the graph that where every 12 hours between days is represented by a white or a gray background.
Right now, the following is the code I have used for the plot and looking for refining it based on the above needs:
p <- ggplot(data=wheel_data, aes(x=date_time, y=rev_counts, group = group, color = group)) +
geom_smooth(method = "loess", span = 0.001) +
scale_x_datetime(breaks = date_breaks("1 day"), label = date_format("%m-%d-%y"))