如何在数字值中添加逗号(值 > 1000)
How do I add a comma to figure values (for values > 1000)
我没有看到 R 或降价的答案。我收到一篇文章的修订稿,他们希望我更改比例值以包含逗号。这可能吗?因此,它将是 337,500 而不是 337,500,等等。非常感谢!
詹姆斯
这是 header 和整个代码段(最重要的部分在实际 AIC 值下方):
#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
对于您的情况,这应该可行!
scale_y_continuous(limits = range(df$AIC),
oob = function(x, ...) x,
expand = c(0.2, 0),
labels = scales::label_comma())
我没有看到 R 或降价的答案。我收到一篇文章的修订稿,他们希望我更改比例值以包含逗号。这可能吗?因此,它将是 337,500 而不是 337,500,等等。非常感谢!
詹姆斯
这是 header 和整个代码段(最重要的部分在实际 AIC 值下方):
#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
对于您的情况,这应该可行!
scale_y_continuous(limits = range(df$AIC),
oob = function(x, ...) x,
expand = c(0.2, 0),
labels = scales::label_comma())