emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Jeremie Juste <jeremiejuste@gmail.com>
To: "Berry,
	Charles" via "General discussions about Org-mode."
Cc: "Berry, Charles" <ccberry@health.ucsd.edu>
Subject: Re: Number format for table results outut from R data.frame/tibble
Date: Sat, 21 Aug 2021 21:55:34 +0200	[thread overview]
Message-ID: <877dgeh8sp.fsf@gmail.com> (raw)
In-Reply-To: <CCAC7632-230E-4614-AD14-53CE590C168A@health.ucsd.edu> (Charles Berry's message of "Sat, 21 Aug 2021 17:39:00 +0000")

Hello, John

For my workflow, I generally use the minimum from xtable and do the
formatting in org-mode using the :post parameter to call another lisp code

That said, as Chuck said, you can go a long way with xtable. In my
attic, I found the following code where I take only the core data from
xtable and do formatting in org-mode. This code may be a little
extravagant on the latex side but, it shows the possibilities.



#+LATEX_HEADER: \usepackage{booktabs}
#+LATEX_HEADER: \usepackage{array}
#+LATEX_HEADER: \usepackage{setspace}
#+LATEX_HEADER: \usepackage{dcolumn}
#+LATEX_HEADER: \usepackage{array}
#+LATEX_HEADER: \usepackage{setspace}

#+Name: add-table-env
#+BEGIN_SRC emacs-lisp :var  table="TABLE" notes="NOTES" caption="CAPTION" :results silent :exports none
(replace-regexp-in-string "\\\\begin{tabular}.*\\S.*\\toprule\\|\\\\end{tabular}" "" 
(format "\\scriptsize{
     \\sisetup{table-format=-2.3, table-space-text-post=***, table-number-alignment=center}
\\begin{tabularx}{\\textwidth}{l *{3}{D..{5.3}}}
\\caption{%s} \\\\
\\multicolumn{1}{c}{colnum 1} &\\multicolumn{1}{c}{colnum 2}   \\\\
  \\cmidrule(lr){1-1}  \\cmidrule(lr){2-2}  

" notes caption table))

#+begin_src R :session foo :results output latex :post add-table-env(*this*, "Some note", "A caption" ) :exports results
  tmp <- tibble(x=1:5, y=x/pi)
	       comment = FALSE,dcolumn=TRUE,booktabs=TRUE
	      ,sanitize.text.function = function(x) {
		x[x=="NA"] <-""

      reply	other threads:[~2021-08-21 19:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-06 15:38 John Hendy
2021-08-06 19:30 ` Berry, Charles via General discussions about Org-mode.
2021-08-21 16:58   ` John Hendy
2021-08-21 17:39     ` Berry, Charles via General discussions about Org-mode.
2021-08-21 19:55       ` Jeremie Juste [this message]

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:

  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=877dgeh8sp.fsf@gmail.com \
    --to=jeremiejuste@gmail.com \
    --cc=ccberry@health.ucsd.edu \
    --cc=emacs-orgmode@gnu.org \
    --subject='Re: Number format for table results outut from R data.frame/tibble' \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Code repositories for project(s) associated with this inbox:


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).