From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rainer M Krug Subject: Re: Make * bold or use colour for export to html and LaTeX Date: Fri, 10 Oct 2014 14:35:50 +0200 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:41171) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XcZQP-0004Of-8x for emacs-orgmode@gnu.org; Fri, 10 Oct 2014 08:36:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XcZQJ-0003vr-PR for emacs-orgmode@gnu.org; Fri, 10 Oct 2014 08:36:01 -0400 Received: from mail-wg0-f46.google.com ([74.125.82.46]:40770) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XcZQJ-0003vX-Go for emacs-orgmode@gnu.org; Fri, 10 Oct 2014 08:35:55 -0400 Received: by mail-wg0-f46.google.com with SMTP id l18so3784871wgh.29 for ; Fri, 10 Oct 2014 05:35:54 -0700 (PDT) In-Reply-To: (Andreas Leha's message of "Fri, 10 Oct 2014 13:23:07 +0100") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Andreas Leha Cc: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Andreas Leha writes: > Hi Rainer, > > Rainer M Krug 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=20 >> >> | | slope | intercept | p | = pm | pb | >> |----------------------------+--------+-----------+---------------+-----= ---------+---------------| >> | quercus_robur.single | -1.358 | 4.76 | | = | | >> | quercus_robur.95 | -1.957 | 5.71 | 3.96e-21 *** | 7.4= 7e-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.=20 > > > 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 =20 > > 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 =3D 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 =3D FALSE, na =3D FALSE,=20 > cutpoints =3D c(0, 0.001, 0.01, 0.05, 0.1, 1),=20 > symbols =3D 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. > > > =2D-=20 Rainer M. Krug email: Rainerkrugsde PGP: 0x0F52F982 --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.22 (Darwin) iQEcBAEBAgAGBQJUN9KmAAoJENvXNx4PUvmCDs0IANCQskTWt+JGbUlTVC0bLW7c baNUn+kkxCH//AZeIa7hoCz2Kkvscl7nQaGlUBo+Z37zMualp2vvLWNNTX0wQ97F LyYv7TBZyQOOrFeBi74DaO7JHcU2tjD8u393kJ2lA1A+7h354EPEF1MnlYePh5Va MYRUzGEnjjr+2kcK58YmwrFWjoTssLFJi3QP5JtTJs4l1HJ4J/K6GgQnACBdG4ZF I+nIjFvxJQBwi4N3zKyxqdO7m0OnEKnxrtbs1QQuUeR5bih/V6DN9oMQriv90MPm lGVqVHnFOv+WVjesYSkoV9W5Efwozqt68w/fxN8OcBgY0w9kbTwz2QHBbaFKrSs= =8vZG -----END PGP SIGNATURE----- --=-=-=--