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

Whitespace padding in print.apa_results_table() #589

Open
mariusbarth opened this issue Jul 12, 2024 · 1 comment
Open

Whitespace padding in print.apa_results_table() #589

mariusbarth opened this issue Jul 12, 2024 · 1 comment

Comments

@mariusbarth
Copy link
Collaborator

Hi @crsh,

results tables from repeated-measures ANOVA may contain df and df.residual columns where sometimes the values are whole numbers, sometimes they have two digits after the decimal point, e.g.:

A data.frame with 7 labelled columns:

                                                        term estimate     conf.int statistic   df df.residual p.value
1                                                  Treatment     .312 [.000, .581]      4.63    2          10    .038
2                                                     Gender     .111 [.000, .437]      2.56    1          10    .141
3                                                      Phase     .264 [.003, .479]     20.87 1.60       15.99  < .001
4                                                       Hour     .185 [.000, .319]     17.01 1.84       18.41  < .001
5                                 Treatment $\\times$ Gender     .218 [.000, .501]      2.86    2          10    .104
6                                  Treatment $\\times$ Phase     .144 [.000, .292]      4.90 3.20       15.99    .012
7                                     Gender $\\times$ Phase     .004 [.000, .000]      0.21 1.60       15.99    .766
8                                   Treatment $\\times$ Hour     .002 [.000, .000]      0.09 3.68       18.41    .979
9                                      Gender $\\times$ Hour     .005 [.000, .000]      0.41 1.84       18.41    .653
10                                      Phase $\\times$ Hour     .023 [.000, .000]      1.15 3.60       35.96    .346
11                Treatment $\\times$ Gender $\\times$ Phase     .021 [.000, .000]      0.64 3.20       15.99    .612
12                 Treatment $\\times$ Gender $\\times$ Hour     .016 [.000, .000]      0.62 3.68       18.41    .641
13                  Treatment $\\times$ Phase $\\times$ Hour     .013 [.000, .000]      0.33 7.19       35.96    .940
14                     Gender $\\times$ Phase $\\times$ Hour     .014 [.000, .000]      0.69 3.60       35.96    .589
15 Treatment $\\times$ Gender $\\times$ Phase $\\times$ Hour     .029 [.000, .000]      0.74 7.19       35.96    .646

term     : Effect 
estimate : $\\hat{\\eta}^2_G$ 
conf.int : 90\\% CI 
statistic: $F$ 
df       : $\\mathit{df}^{\\mathrm{GG}}$ 
... (2 more labels)
attr(,"class")
[1] "apa_results" "list" 

For better legibility, I wondered whether we should pad the whole numbers with whitespace in print.apa_results_table(), such as:

$table
A data.frame with 7 labelled columns:

                                                        term estimate     conf.int statistic   df df.residual p.value
1                                                  Treatment     .312 [.000, .581]      4.63 2          10       .038
2                                                     Gender     .111 [.000, .437]      2.56 1          10       .141
3                                                      Phase     .264 [.003, .479]     20.87 1.60       15.99  < .001
4                                                       Hour     .185 [.000, .319]     17.01 1.84       18.41  < .001
5                                 Treatment $\\times$ Gender     .218 [.000, .501]      2.86 2          10       .104
6                                  Treatment $\\times$ Phase     .144 [.000, .292]      4.90 3.20       15.99    .012
7                                     Gender $\\times$ Phase     .004 [.000, .000]      0.21 1.60       15.99    .766
8                                   Treatment $\\times$ Hour     .002 [.000, .000]      0.09 3.68       18.41    .979
9                                      Gender $\\times$ Hour     .005 [.000, .000]      0.41 1.84       18.41    .653
10                                      Phase $\\times$ Hour     .023 [.000, .000]      1.15 3.60       35.96    .346
11                Treatment $\\times$ Gender $\\times$ Phase     .021 [.000, .000]      0.64 3.20       15.99    .612
12                 Treatment $\\times$ Gender $\\times$ Hour     .016 [.000, .000]      0.62 3.68       18.41    .641
13                  Treatment $\\times$ Phase $\\times$ Hour     .013 [.000, .000]      0.33 7.19       35.96    .940
14                     Gender $\\times$ Phase $\\times$ Hour     .014 [.000, .000]      0.69 3.60       35.96    .589
15 Treatment $\\times$ Gender $\\times$ Phase $\\times$ Hour     .029 [.000, .000]      0.74 7.19       35.96    .646

term     : Effect 
estimate : $\\hat{\\eta}^2_G$ 
conf.int : 90\\% CI 
statistic: $F$ 
df       : $\\mathit{df}^{\\mathrm{GG}}$ 
... (2 more labels)
attr(,"class")
[1] "apa_results" "list"  

What do you think? I would be happy to provide a PR for this one.

@crsh
Copy link
Owner

crsh commented Jul 15, 2024

Hi Marius, yes this is a great idea and since great minds thing alike: #51 ;)

It's also been brought up on the pandoc-side, but there seems to be little interest (the issue is 5 years old).

Padding with white space will work in the R console but doesn't translate well into output in the rendered documents, right? So I don't think we should do this in the apa_results_table-object. I think there are three work packages here that we could tackle in separate PRs (and also release separately):

  1. We add the white space in the print method for apa_results-objects. This may require a little thought to figure out which columns should do this. For example, do we also want to do this for conf.int to fix spacing when the signs vary (I think this would be super nice).
  2. Implement the D column using the dcolumn LaTeX package in apa_table(). In many situations you can get by via aligning the colums right if the all have the same number of digits. But this often fails conf.int and the df columns, so a proper fix would be super nice.
  3. In Word this can actually be done by hand, but we could explore if we can get away with white space padding here as well. Unless someone wants to write a Lua filter for this. 😬

What do you think?

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

2 participants