I'm working on a time series analysis of data from the United States Department of Labor, hopefully to present to my employer. As an example, plot the total number of employees working in the United States, on a monthly basis. The plot is fine in RStudio, but the left and right sides are clipped when I output to HTML, PDF or Word, using Knitting.
Here is the code in R:
library(tidyverse)
library(fpp3)
All_Employees_a <- read_csv('https://raw.githubusercontent.com/InfiniteCuriosity/predicting_labor/main/All_Employees.csv', col_select = c(4,5))
All_Employees_a <- All_Employees_a %>%
rename(Month = Label) %>%
mutate(Month = yearmonth(Month)) %>%
filter(Month > yearmonth("2015 Jan")) %>%
as_tsibble(index = Month)
All_Employees_a %>%
gg_season(y = Value, labels = "both")
labs(title = "Total number of employees by month", y = "Number of employees per month")
Here is the plot in RStudio, which is fine:

Here is what it looks like when the file is Knitted. The results are the same whether the knitting is HTML, PDF or Word:
Things I've tried: I've changed every setting I can find to Knit documents (there are no parameters), changed the margins, looked for all options available when I hit the tab key for every function, and looked up help.
More information on Seasonal Plots can be found in the book Forecasting Principles and Practice (which I very highly recommend), https://otexts.com/fpp3/seasonal-plots.html
None of these have solved the issue. Any help or advice would be warmly appreciated.
Thanks!
CodePudding user response:
For me, increasing figure width solved the problem for outputs in html, pdf and word.
Try {r, fig.width=10}.

