When I try to knit my RMarkdown file to a PDF, for some reason I can't get the r code chunks to fit inside the margins.
I have tried multiple solutions including
opts_chunk$set(tidy.opts=list(width.cutoff=40),tidy=TRUE)
I got this solution from the link below.
In R markdown in RStudio, how can I prevent the source code from running off a pdf page?
But as you can see below, even when set this, the code still runs off the page.
Putting
out.width='50%'
in my r chunck headersJust trying to space out my code so there are no long lines.
But nothing has worked.
Here is what the problem looks like
And here is the corresponding RMarkdown code
```{r message = FALSE , tidy=TRUE, out.width='50%'}
## bunch of code
poverty_status_table <-
create_table(df, "POVERTY STATUS IN THE PAST 12 MONTHS", year) %>%
mutate(
POVERTY.STATUS.IN.THE.PAST.12.MONTHS =
gsub(
"^Workers 16 years and over for whom poverty status is determined - ",
"",
POVERTY.STATUS.IN.THE.PAST.12.MONTHS
)
) %>%
mutate(
POVERTY.STATUS.IN.THE.PAST.12.MONTHS = gsub(
" of the poverty level",
"",
POVERTY.STATUS.IN.THE.PAST.12.MONTHS
)
) %>%
rename(Poverty.status =
POVERTY.STATUS.IN.THE.PAST.12.MONTHS) %>%
filter(Poverty.status !=
"Workers 16 years and over for whom poverty status is determined")
## more code
As you can see in the image, my goal is to have the code stay inside the margins.