I'm working with a dataset of 5k finish times that looks a little bit like this:
"15:34"
"14:23"
"17:34"
and so on, there's a lot, but they're all formatted like that. I'm able to convert all of them to POSIXct, and store them in a data frame to make using ggplot2 easier, but for the life of me, I cannot get ggplot to change colors. The fill command doesn't work, the graph just remains grey.
I've tried just referencing the POSIXct object I made, but ggplot throws an error and tells me it doesn't work well with POSIXct. The only way I've been able to display a histogram is by storing it in a dataframe.
The code I'm currently using looks like:
#make the data frame
df <- data.frame(
finish_times = times_list)
#set the limits on the x axis as datetime objects
lim <- as.POSIXct(strptime(c('2018-3-18 14:15', '2018-3-18 20:00'), format = "%Y-%m-%d %M:%S"))
#making the plot
ggplot(data = df, aes(x = finish_times)) +
geom_histogram(fill = 'red') + #this just doesn't work
stat_bin(bins = 30) +
scale_x_datetime(labels = date_format("%M:%S"),
breaks = date_breaks("1 min"),
limits = lim) +
labs(title = "2017 5k finishers",
x='Finish Times',
y= 'Counts')
I've crawled through a lot of ggplot and R documentation, and I'm not sure what I'm missing, I appreciate all help, thanks