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

add.significance.stars output #230

Closed
kofm opened this issue Dec 3, 2015 · 4 comments
Closed

add.significance.stars output #230

kofm opened this issue Dec 3, 2015 · 4 comments

Comments

@kofm
Copy link

kofm commented Dec 3, 2015

Hi,
when using the options add.significance.stars in pander() mehod the output is not well interpreted by pandoc that recognizes the asterisks as markup code for bold and italic fonts.
Here's a minimal example:

> ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
> trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
> group <- gl(2, 10, 20, labels = c("Ctl","Trt"))
> weight <- c(ctl, trt)
> lm.D9 <- lm(weight ~ group)
> lm.D90 <- lm(weight ~ group - 1) # omitting intercept
> 
> anova(lm.D9)
Analysis of Variance Table

Response: weight
          Df Sum Sq Mean Sq F value Pr(>F)
group      1 0.6882 0.68820  1.4191  0.249
Residuals 18 8.7292 0.48496               
> pander(anova(lm.D9),add.significance.stars = T)

----------------------------------------------------------
    &nbsp;       Df   Sum Sq   Mean Sq   F value   Pr(>F) 
--------------- ---- -------- --------- --------- --------
   **group**     1    0.6882   0.6882     1.419           

 **Residuals**   18   8.729     0.485      NA        NA   
----------------------------------------------------------

Table: Analysis of Variance Table

Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

The last string ("Signif. codes") does not render well in PDF output as you can see here:
image

If i manually copy&paste pander() output and escape the asterisks like this:

Codici sign.:  0 '\*\*\*' 0.001 '\*\*' 0.01 '\*' 0.05 '\.' 0.1 ' ' 1 

then it renders well from md to pdf with pandoc.

image

Thanks

@daroczig
Copy link
Member

daroczig commented Dec 9, 2015

Sorry for the long delay with my reply -- thanks for reporting this, I hope the above commit resolves the issue. Looking forward to any feedback. Thanks, Gergely

@kofm
Copy link
Author

kofm commented Dec 11, 2015

Thanks for the fix!
It appears to still have some problems.

> pander(anova(model),add.significance.stars=T,missing="",caption="Risultati ANOVA")

--------------------------------------------------------------
    &nbsp;       Df   Sum Sq   Mean Sq   F value   Pr(>F)     
--------------- ---- -------- --------- --------- --------- --
 **treatment**   2    0.2317   0.1158     2.28     0.1036     

  **variety**    83   22.31    0.2688     5.291   1.077e-30   

 **Residuals**  418   21.24    0.05081                        
--------------------------------------------------------------

Table: Risultati ANOVA

Signif. codes:  0 '\*\*\*' 0.001 '\*\*' 0.01 '\*' 0.05 '.' 0.1 ' ' 1

Significance stars are not added anymore to the table and it also add another not needed empty column after Pr(>F).
Here's how the same output should be (imho):

----------------------------------------------------------
    &nbsp;       Df   Sum Sq   Mean Sq   F value   Pr(>F) 
--------------- ---- -------- --------- --------- --------
 **treatment**   2    0.2317   0.1158     2.28            

  **variety**    83   22.31    0.2688     5.291    * * *  

 **Residuals**  418   21.24    0.05081                    
----------------------------------------------------------

Table: Risultati ANOVA

Signif. codes:  0 '\*\*\*' 0.001 '\*\*' 0.01 '\*' 0.05 '.' 0.1 ' ' 1

Thanks again

@daroczig daroczig reopened this Dec 11, 2015
@daroczig
Copy link
Member

Ah, right -- sorry for the above typo, it should be fixed now. Please note that the add.signigicance.stars feature does not replace the P values with stars, but instead adds a new column including the stars. Please let me know how it works for you.

@kofm
Copy link
Author

kofm commented Dec 16, 2015

Works like a charm!
Thank you very much for your awesome work

d> pander(anova(model),add.significance.stars = T,missing="")

-----------------------------------------------------------------
    &nbsp;       Df   Sum Sq   Mean Sq   F value   Pr(>F)        
--------------- ---- -------- --------- --------- --------- -----
  **variety**    83   8.309    0.1001     5.051   5.914e-29 * * *

 **treatment**   2    0.1377   0.06885    3.474    0.0319     *  

 **Residuals**  418   8.285    0.01982                           
-----------------------------------------------------------------

Table: Analysis of Variance Table

Signif. codes:  0 '\*\*\*' 0.001 '\*\*' 0.01 '\*' 0.05 '.' 0.1 ' ' 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants