I have a data set that runs for 7 days producing cumulative counts for each of those days broken up into 15 min periods
The time period starts from 12 o'clock in the morning and runs until 12 o clock the following day. The order is important.
Below is a made up sample (apologies for the messy nature)
library(tidyverse)
add_break <- function(check) {
Zero_break <- paste(check, '00', sep=":") %>% as_tibble()
fifteen_break <- paste(check, '15', sep=":") %>% as_tibble()
thirty_break <- paste(check, '30', sep=":") %>% as_tibble()
fortyfive_break <- paste(check, '45', sep=":") %>% as_tibble()
bind_rows(Zero_break, fifteen_break, thirty_break, fortyfive_break)
}
# Create the Levels for the Time for every 15 mins
pm <- paste(seq(12,23), sep='') %>% as_tibble()
am <- paste(0, seq(00,09), sep='') %>% as_tibble()
am_2 <- paste(seq(10,11), sep='') %>% as_tibble()
clock <- pm %>% bind_rows(am, am_2)
intervals <- map_df(clock$value, add_break)
# Create Random data for cumsum
mydf <- intervals %>%
mutate(MON = cumsum(sample(1:100,size = 96,replace = TRUE)),
TUE = cumsum(sample(1:100,size = 96,replace = TRUE)),
WED = cumsum(sample(1:100,size = 96,replace = TRUE)),
THUR = cumsum(sample(1:100,size = 96,replace = TRUE)),
FRI = cumsum(sample(1:100,size = 96,replace = TRUE)),
SAT = cumsum(sample(1:100,size = 96,replace = TRUE)),
SUN = cumsum(sample(1:100,size = 96,replace = TRUE)))
mydf$AVG <- round(rowMeans(mydf[,2:8]),2)
ggplot(mydf, aes(x=reorder(value, MON), y = MON)) +
geom_line() +
geom_line(aes(x=reorder(value, TUE), y = TUE), colour = 'red')
I then try and create a line graph where i want to create very light colours for the days of the week and then a pretty strong colour for the average
Unfortunately when i run the code i get the following error
geom_path: Each group consists of only one observation. Do you need to adjust the group aesthetic? geom_path: Each group consists of only one observation. Do you need to adjust the group aesthetic?
Can Anyone help?