emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Brett Presnell <presnell@member.fsf.org>
To: Jeremie Juste <jeremiejuste@gmail.com>
Cc: Brett Presnell <presnell@member.fsf.org>,
	"Berry, Charles" <ccberry@health.ucsd.edu>,
	"Berry,
	Charles via General discussions about Org-mode."
	<emacs-orgmode@gnu.org>
Subject: Re: na=\"nil\" in ob-R.elo
Date: Sun, 17 Jan 2021 16:48:23 -0500	[thread overview]
Message-ID: <87y2grck0o.fsf@ufl.edu> (raw)
In-Reply-To: <87im7xuhrh.fsf@gmail.com>


I can verify that the :post work-around suggested by Chuck and
implemented by Jeremie works as advertised.

FWIW, I would certainly prefer to see the implementation
org-babel-R-write-object-command changed so that the work-around
wouldn't be necessary.

Thank you to both Chuck and Jeremie for looking into this.


Jeremie Juste <jeremiejuste@gmail.com> writes:

> [External Email]
>
> Hello,
>
> Thanks for the feedback
>
> || On Saturday, 16 Jan 2021 at 00:19, Berry, Charles" via "General discussions about Org-mode. wrote:
>> You can use a :post header to customize outputs like this to make them
>> more pleasing. Or just use your own
>> `org-babel-R-write-object-command'.
>
>
> As a quick work around you can use
>
> #+name: remove-nil
> #+begin_src emacs-lisp :var tbl=""
>    (mapcar (lambda (row)
>              (mapcar (lambda (cell)
>                        (if (equal "nil" cell)
>                            ""
>                         cell))
>                      row))
>            tbl)
>
> #+end_src
>
>
>
> #+BEGIN_SRC R  :results value :colnames yes :post remove-nil[:colnames yes](*this*)
> data.frame(A=c(NA,1,1,1,1),B=c(1,2,NA,4,4))
> #+end_src
>
> #+RESULTS:
> | A | B |
> |---+---|
> |   | 1 |
> | 1 | 2 |
> | 1 |   |
> | 1 | 4 |
> | 1 | 4 |
>
>
>
>>> Probably a silly question, but in ob-R.el, what is the reason for
>>> setting na=\"nil\" when defining org-babel-R-write-object-command?  Is
>>> this an elisp compatibility thing?
>>>
>>
>> I don't get it either. The value corresponding to the NA becomes a string in emacs-lisp whether \"nil\" or \"\" is used.
>> So when passed to elisp via a :post header referencing an emacs-lisp
>> src block, its treated as a string.
>
> Thanks Chuck for pointing this out. R users are used to handle NA but in
> this particular case where empty string and NA are treated
> the same, I'm not sure the nil feature is very useful. If it does not break
> anything else I will consider removing it.
>
>
> Best regards,



  reply	other threads:[~2021-01-17 21:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-14 23:42 na=\"nil\" in ob-R.elo Brett Presnell
2021-01-16  0:19 ` Berry, Charles via General discussions about Org-mode.
2021-01-16 13:35   ` Jeremie Juste
2021-01-17 21:48     ` Brett Presnell [this message]
2021-02-06 20:05   ` 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:
  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=87y2grck0o.fsf@ufl.edu \
    --to=presnell@member.fsf.org \
    --cc=ccberry@health.ucsd.edu \
    --cc=emacs-orgmode@gnu.org \
    --cc=jeremiejuste@gmail.com \
    /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).