emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Rainer M Krug <Rainer@krugs.de>
To: Andreas Leha <andreas.leha@med.uni-goettingen.de>
Cc: emacs-orgmode@gnu.org
Subject: Re: Make * bold or use colour for export to html and LaTeX
Date: Fri, 10 Oct 2014 14:35:50 +0200	[thread overview]
Message-ID: <m2ppe0qezd.fsf@krugs.de> (raw)
In-Reply-To: <olu8ukonmfo.fsf@vpn-2047.gwdg.de> (Andreas Leha's message of "Fri, 10 Oct 2014 13:23:07 +0100")

[-- Attachment #1: Type: text/plain, Size: 3192 bytes --]

Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:

> Hi Rainer,
>
> Rainer M Krug <Rainer@krugs.de> writes:
>> Hi
>>
>> I want to highlight the cells in the table below with "***" by using
>> color red for the font, "**' by using green for the font, ... or, if not possible, bold. Is any of this possible?
>>
>> The table is generated in R, so the ascii package might help (just
>> thinking about it while typing)?
>>
>> Thanks,
>>
>> Rainer 
>>
>> |                            |  slope | intercept | p             |           pm |            pb |
>> |----------------------------+--------+-----------+---------------+--------------+---------------|
>> | quercus_robur.single       | -1.358 |      4.76 |               |              |               |
>> | quercus_robur.95           | -1.957 |      5.71 | 3.96e-21 ***   | 7.47e-07 *** |  7.60e-09 *** |
>> | quercus_robur.90           | -1.752 |      5.42 | 3.43e-02 *    |   7.18e-02 . |    4.79e-02 * |
>> | quercus_robur.85           | -1.773 |      5.41 | 4.11e-01      |     8.33e-01 |      9.38e-
>
>
> I am not sure to understand your question correctly, but if the table is
> R generated anyway, why not use R to provide the formatting for org?

You do - bold or in colour. 

>
>
> Like -- as a start -- this function, that does the simplest of those and
> replaces "***" with bold:

This looks very promising, but I would also like to keep the stars, so I
would like to have "3.96e-21 ***" in bold (or even in color`). But I am
going to start with your example.

Thanks,

Rainer
 

>
> boldpattern <- " \\*\\*\\*$"
> tbl <- apply(tbl, 2,
>              function(x) ifelse(grepl(boldpattern, x),
>                                 paste0("*", gsub(boldpattern, "", x), "*"),
>                                 x))
>
>
> Here as full example in action:
>
> ## ---------------------------------- ##
> ## create a table                     ##
> ## ---------------------------------- ##
>
> ## from ?lm
> 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
> ## extract the coefficients
> tbl <- summary(lm.D90)$coefficients
> ## add the signif codes
> tbl[,4] <- paste(tbl[,4],
>                  symnum(tbl[,4], corr = FALSE, na = FALSE, 
>                         cutpoints = c(0, 0.001, 0.01, 0.05, 0.1, 1), 
>                         symbols = c("***", "**", "*", ".", " ")))
> tbl
>
>
> ## ---------------------------------- ##
> ## make them 'org-bold'               ##
> ## ---------------------------------- ##
> boldpattern <- " \\*\\*\\*$"
> tbl <- apply(tbl, 2,
>              function(x) ifelse(grepl(boldpattern, x),
>                                 paste0("*", gsub(boldpattern, "", x), "*"),
>                                 x))
> tbl
>
>
> HTH,
> Andreas
>
> PS: The usual "don't use the signif.codes" applies.
>
>
>

-- 
Rainer M. Krug
email: Rainer<at>krugs<dot>de
PGP: 0x0F52F982

[-- Attachment #2: Type: application/pgp-signature, Size: 494 bytes --]

  reply	other threads:[~2014-10-10 12:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-10 10:29 Make * bold or use colour for export to html and LaTeX Rainer M Krug
2014-10-10 12:23 ` Andreas Leha
2014-10-10 12:35   ` Rainer M Krug [this message]
2014-10-10 16:13 ` Aaron Ecay
2014-10-13 11:29   ` pgfplotstable and org -WAS: " Rainer M Krug

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2ppe0qezd.fsf@krugs.de \
    --to=rainer@krugs.de \
    --cc=andreas.leha@med.uni-goettingen.de \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).