Reputation: 589
I don't see an answer for R or markdown. I received for revisions for an article, and they want me to change the scale values to include a comma. Is this possible? Thus, it would be 337,500 rather than 337500, etc. Thanks much!
James
Here's the header and the entirety of the code segment (the most important part is below the actual AIC values):
#header
---
fig: no crop
geometry: left=1mm, right=1mm, top=1mm, bottom=1mm, asymmetric
indent: TRUE
output:
word_document:
reference_docx: my-styles.docx
html_document:
df_print: paged
fig_caption: yes
includes:
in_header: my_header.tex
pdf_document: default
header-includes:
- \usepackage{placeins}
- \usepackage{indentfirst}
- \usepackage{setspace}\doublespacing
- \usepackage{lineno}
- \linenumbers
---
cleanup = theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.background = element_blank(),
axis.line = element_line(color = "black"))
aic = c(AIC(logLik(ed_crime.model.v.p.int.pop)),AIC(logLik(ed_crime.model.v.p.int.pop_percap)), AIC(logLik(ed_crime.model.v.p.int.pop_ed)),
AIC(logLik(ed_crime.model.v.p.int.pop_off)),
AIC(logLik(ed_crime.model.v.p.int.pop_wht)),
AIC(logLik(ed_crime.model.v.p.int.pop_difdem)),
AIC(logLik(ed_crime.model.v.p.int.pop_blk)),
AIC(logLik(ed_crime.model.v.p.int.pop_mgr)),
AIC(logLik(ed_crime.model.v.p.int.pop_ba)),
AIC(logLik(ed_crime.model.v.p.int.pop_propov)),
AIC(logLik(ed_crime.model.v.p.int.pop_asian)),
AIC(logLik(ed_crime.model.v.p.int.pop_hs)),
AIC(logLik(ed_crime.model.v.p.int.pop_nghs)), AIC(logLik(ed_crime.model.v.p.int.pop_sc)), AIC(logLik(ed_crime.model.v.p.int.pop_mapl)), AIC(logLik(ed_crime.model.v.p.int.pop_unempl)), AIC(logLik(ed_crime.model.v.p.int.pop_medinc)))
variables <- c("Population + Pop Dense", "Per Capita Income", "Education Spending", "Law Enforcement", "White", "Political Leanings", "Black", "Median Rent", "Education: BA", "Proportion 5-17 in Poverty", "Asian", "Education: HS", "Education: did not graduate HS", "Education: some college","Education: MA/greater", "Unemployment", "Median Income") #"Complete Null",
#, "Latino" "Two or more races",
df <- data_frame(variables = variables, AIC = aic)
colourCount = length(unique(df$variables))
getPalette = colorRampPalette(brewer.pal(9, "Dark2"))
a <- df%>%
mutate(name = fct_reorder(variables, desc(AIC)))%>%
ggplot(aes(x = name, y = AIC, fill= variables))+
geom_col()+
coord_flip()+
theme(legend.position="right")+
xlab("Variables")+
ylab("AIC (DV Crime)")+
scale_fill_manual(values = getPalette(colourCount))+
guides(fill=FALSE)+
ggtitle("8a: Comparative Variance")+
set_theme(title.size = .6)+
scale_y_continuous(limits = range(df$AIC),
oob = function(x, ...) x,
expand = c(0.2, 0)) +
theme(axis.text.x = element_text(size = 5),
axis.text.y = element_text(size = 6),
axis.title.x = element_text(size = 8),
axis.title.y = element_text(size = 8))+
cleanup
Upvotes: 1
Views: 57
Reputation: 1560
In your case, this should work!
scale_y_continuous(limits = range(df$AIC),
oob = function(x, ...) x,
expand = c(0.2, 0),
labels = scales::label_comma())
Upvotes: 2