emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: John Hendy <jw.hendy@gmail.com>
To: emacs-orgmode <emacs-orgmode@gnu.org>
Subject: Number format for table results outut from R data.frame/tibble
Date: Fri, 6 Aug 2021 10:38:09 -0500	[thread overview]
Message-ID: <CA+M2ft_iE4Gd9vXkEV9rmShY7-GBfQHY7Fpc2y99E6W4pHRC_w@mail.gmail.com> (raw)


I'm wondering how to align the results from the R buffer (which I
like) vs. the results printed by Org-mode for table results. Here's a
toy example:

#+begin_src R :session foo :output results :type table :results value

tmp <- tibble(x=1:5, y=x/pi)

In org, I get this:

| 1 | 0.318309886183791 |
| 2 | 0.636619772367581 |
| 3 | 0.954929658551372 |
| 4 |  1.27323954473516 |
| 5 |  1.59154943091895 |

In the buffer, I get this:
      x     y
  <int> <dbl>
1     1 0.318
2     2 0.637
3     3 0.955
4     4 1.27
5     5 1.59

From the tibble side, R points one to the pillar package[1], which
indeed affects the output in the buffer, but not in the Org results.

#+begin_src R :session foo :output results :type table :results value

tmp <- tibble(x=1:5, y=x/pi)

# A tibble: 5 × 2
      x     y
  <int> <dbl>
1     1   0.3
2     2   0.6
3     3   1.
4     4   1.
5     5   2.

The last example here touches on accomplish this[2]... but is the only
method to write an elisp block that post-process my R results? It
seems so enticing that R can output the correct format... can Org
latch onto the exact output somehow?

I also discovered the round_df package[3], so I could bring that into
the mix and round flexibly, it seems. I don't *really* want to round,
though, I just want more digestible output.

Many thanks for any pointers, I'm suspecting the answer is before my
eyes, but I haven't figured out the proper incantation of :results,
:type, :wrap, etc...

Best regards,

[1] https://pillar.r-lib.org/articles/digits.html
[2] https://orgmode.org/manual/Results-of-Evaluation.html
[3] https://rdrr.io/cran/forestmangr/man/round_df.html

             reply	other threads:[~2021-08-06 15:38 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-06 15:38 John Hendy [this message]
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

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=CA+M2ft_iE4Gd9vXkEV9rmShY7-GBfQHY7Fpc2y99E6W4pHRC_w@mail.gmail.com \
    --to=jw.hendy@gmail.com \
    --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).