emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Berry, Charles" via "General discussions about Org-mode." <emacs-orgmode@gnu.org>
To: Damien Cassou <damien@cassou.me>
Cc: org-mode mailing list <emacs-orgmode@gnu.org>
Subject: Re: Bug: Babel+R handles spaces wrongly in tables [9.3.6 (release_9.3.6 @ /home/cassou/.emacs.d/lib/org/lisp/)]
Date: Sun, 6 Sep 2020 18:23:19 +0000	[thread overview]
Message-ID: <71761E05-7D0A-4FEF-8BAF-4C776A2FC17E@health.ucsd.edu> (raw)
In-Reply-To: <87wo172laf.fsf@cassou.me>



> On Sep 6, 2020, at 4:32 AM, Damien Cassou <damien@cassou.me> wrote:
> 
> 
> Hi,
> 
> it seems that, if a cell within a table contains a space, the
> corresponding value passed as parameter to a R script will be
> wrong.


Not exactly. Your ECM has one column, and using both columns removes the issue.

Here is another ECM that illustrates the bug:

#+begin_src R :results output :var accounts=(identity '("A B" "C")) 
print(accounts)
#+end_src


The bug is in `org-babel-R-assign-elisp' which attempts to get the number of elements in each line of a table, but when the table has just one row or column it gets this wrong.


> Please find a very simple org file attached to this email. I
> expect the length of the variable to be 2 (which is the length of '("A
> B" "C") and not 3. Apparently, R receives this array instead: '("A B"
> "C" nil).
> 

Actually the length should be 1, i.e. a data.frame with a single column of two elements.

BTW, C-c C-v C-v with point in the src block will show you what R `receives'.

Unfortunately, there are other cases where the variable assignment does not work seamlessly for R src blocks.  There are workarounds, but they are ungainly - like using a src block for another language to render the table and then using a noweb reference to it to import the data. 

HTH,
Chuck


  reply	other threads:[~2020-09-06 18:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-06 11:32 Bug: Babel+R handles spaces wrongly in tables [9.3.6 (release_9.3.6 @ /home/cassou/.emacs.d/lib/org/lisp/)] Damien Cassou
2020-09-06 18:23 ` Berry, Charles via General discussions about Org-mode. [this message]
2020-09-07  4:40   ` Bastien
2020-09-07  4:44     ` Bastien
2020-12-19 13:45 ` Jeremie Juste
2021-05-02  3:52   ` Bastien
2021-05-02 22:45     ` 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=71761E05-7D0A-4FEF-8BAF-4C776A2FC17E@health.ucsd.edu \
    --to=emacs-orgmode@gnu.org \
    --cc=ccberry@health.ucsd.edu \
    --cc=damien@cassou.me \
    /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).