r - Scientific notation in knitr: How to improve typography -


It has always been one of the great features of knit, which is intelligent globular, so you avoid many sprintf Can be / round / paste 0 location.

A customer has complained that I had given the decimal wrongly, I found that forgetting $ $ for those numbers is very dangerous that can be printed in scientific notation. But the same customer complained that my appearance looks like ugly using scientific notation because mathematics like latex does not match main font.

scientific notation

After the comment of yihui on the closed issue , $$ are required.

Does anyone have an intelligent solution for this? Currently, I'm formatting everything with Sprintf like old days.

  --- Production: html_document: theme: cosmo --- I use the Cosmo theme as it clearly shows the typographic problem more. `` (R) option (points = 2) mean = c (2.31310 9 34, 1.23456e-7) stud = c (0.31310 9 34, 6.54321 e-7) `` number of offset expression ("numeral") With the standard deviation of `r std [1]` `r means [1]` it looks good; it means `r '[2]` standard study [2]' with standard deviation is note that insult It looks like "1.23510" means $ `R = $ [RED] with the standard deviation of $` RS [2] `$ [2]` $   

You always re-output the output hook to avoid inline Can be very clear sprintf / round / paste0 ...

  knitr :: knit_hooks $ set (inline = function (x) {knitr ::: format_sci (X, '' md ''}})  

This form will be 1.23 & amp; Use of time syntax; 10 ^ -7 ^ for scientific notation, which is only HTML to your output format, if it should work well.

This is a simple problem for a particular type of output format, but it is difficult when you want the number formatting to be portable in all formats, including HTML, Word, LaTeX, etc. This is the reason that $$ became necessary in knitted 1.7.


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

javascript - amcharts makechart not working -

java - Algorithm negotiation fail SSH in Jenkins -