Hello,
I would like create three plots on the top of each other with a common axis (months-year) for each of my three clients NM, F, and NCF.
I would like only the completed part of my data.
I originally have daily data which I converted to monthly data. I would like to show my monthly times series graphs on the top of each other (one for each client). Later I will do this for my ggseasonal plot and other time series graphs. This will help my audience understand the patterns I am talking about for each of the clients and how they compare to each other.
Here is what my code looks like:
# Data
status <- c('completed', 'completed', 'cancelled', 'completed', 'cancelled', 'completed', 'completed','completed', 'cancelled')
client <- c('NM','NM', 'F','F','F','NM' ,'NCF', 'NCF', 'F')
audit_date <- c('2017-01-01', '2017-01-03','2018-03-02', '2018-03-03', '2019-02-04', '2019-02-03', '2019-04-05',
'2019-04-05','2019-04-08') # Daily data to be converted to monthly data
d00 <- tibble(status, client, audit_date)
d00
d11 <- d00
d11 <- d00 %>%
mutate(year.month = substr(audit_date, 0 , 7)) %>%
group_by(year.month, client) %>%
summarize( total.audits = sum(status == 'completed'))
d11
# Converting to time series (NOT working)
d11.ts <- d11 %>%
as_tsibble(index = year.month)
d11.ts
# Plot
# I want to have an autoplot for each of the clients. I can do this for each of the clients alone like below
# However to get the graph below, I separated my data set into three parts where each part deals with one of the three customers.
# This is the graph for F. It won't show.
# I would like this graph for each of the customers above (three plots but with the same axis)
comp_audits.F <- autoplot(ds.ts.F, color = 'red', geom = 'point') +
scale_x_date(
date_labels = "%b %y",
breaks = '1 month') +
scale_y_continuous(
breaks = seq(min(ds.ts.F$total.audits),
max(ds.ts.F$total.audits),
by = 100),
limits = c(0, 700)
) +
theme(axis.text.x = element_text(angle = 90, hjust = 1)) +
# geom_point(col = 'green', size = 3, pch = 16) +
# geom_smooth(method = 'loess', se = F) +
labs(subtitle = 'subtitle',
y = "CA",
X = "Month-Year",
title = "Time Series Plot for F")
comp_audits.F
Thank you!