Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Commas between numbers (df. N) #21

Open
alanpaulkwan opened this issue Dec 3, 2016 · 2 comments
Open

Commas between numbers (df. N) #21

alanpaulkwan opened this issue Dec 3, 2016 · 2 comments

Comments

@alanpaulkwan
Copy link

It would be great to have an option (or default) to put commas in between numbers that are integers.

4,234,332

@leifeld
Copy link
Owner

leifeld commented Dec 3, 2016

Agreed. Just two thoughts:

  1. We would need to make sure that it doesn't interfere with decimal point alignment using the dcolumn package, which uses points as the decimal separator. In some locales (e.g., German), a comma is used for that. So having commas is not a general solution, but implementing a general solution might interfere with internationalization issues. Just something to think about, but perhaps not a real problem.
  2. In an ideal case, one would transform the variables before they enter the model, such that there are no long numbers. E.g., convert meters into kilometers or thousands of kilometers etc.

@leifeld leifeld added this to the 1.36.26 milestone Mar 15, 2019
@MatthieuStigler
Copy link
Contributor

Hi

I was interested in this request too! Here are my questions/comments:

  1. I believe just having an alternative thousand separator, using format(., big.marks = ...) where marks are either ', , or space should not be a big issue. It seems version with and without dcolumn handles this!? See examples below, where I hack the N obs number. Is the relevant code the block starting with write GOF block, lines 3139 onwards in texreg.R

  2. Internationalization: yes, this is a big issue. A look at that page shows notable difference, especially with decimal separator. Clearly, if someone want to use , instead of ., might create some issues... But how is this handled currently? Does texreg offer alternative , decimal separators anyway?

suppressMessages(library(texreg))
remotes::install_github("MatthieuStigler/matPkg", upgrade = "never")
library(matPkg)
example(texreg, echo=FALSE)


##
out <- texreg(list(model.1, model.2), booktabs = TRUE, dcolumn = TRUE, use.packages = FALSE)
out_noDC <- texreg(list(model.1, model.2), booktabs = TRUE, dcolumn = FALSE, use.packages = FALSE)

out2 <-  gsub("108", format(1011288, big.mark = "' "), out)
out3 <-  gsub("108", format(1011288, big.mark = ","), out)
out4 <-  gsub("108", paste("$", format(1011288, big.mark = "\\\\\\\\\\\\,"), "$", sep=""), out)

out2_noDC <-  gsub("108", format(1011288, big.mark = "' "), out_noDC)
out3_noDC <-  gsub("108", format(1011288, big.mark = ","), out_noDC)
out4_noDC <-  gsub("108", paste("$", format(1011288, big.mark = "\\\\\\\\\\\\,"), "$", sep=""), out_noDC)



## this (custom, internal) funciton will create a pdf in getwd():
mat_table_to_pdf(out2, file = "example_prime.tex")
mat_table_to_pdf(out3, file = "example_period.tex")
mat_table_to_pdf(out4, file = "example_space.tex")

mat_table_to_pdf(out2_noDC, file = "example_noDC_prime.tex")
mat_table_to_pdf(out3_noDC, file = "example_noDC_period.tex")
mat_table_to_pdf(out4_noDC, file = "example_noDC_space.tex")

plain, period

example_noDC_period

plain, prime

example_noDC_prime

plain, space

example_noDC_space

dcolumn, period

example_period

dcolumn, prime

example_prime

dcolumn, space

example_space

@leifeld leifeld removed this from the 1.36.26 milestone May 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants