emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Aaron Ecay <aaronecay@gmail.com>
To: Rainer M Krug <Rainer@krugs.de>,
	Andreas Leha <andreas.leha@med.uni-goettingen.de>
Cc: emacs-orgmode@gnu.org
Subject: Re: org tables into R?
Date: Tue, 06 Jan 2015 12:49:25 -0500	[thread overview]
Message-ID: <87lhlfvly2.fsf@gmail.com> (raw)
In-Reply-To: <m2sifo3u9a.fsf@krugs.de>

Hi Rainer and Andreas,

2015ko urtarrilak 6an, Rainer M Krug-ek idatzi zuen:
> What would definitely solve the issue is if the string containing the
> tabs would use \t instead - but I have no idea how this could be
> achieved easily.

This could be achieved by modifying the call to orgtbl-to-csv in
org-babel-R-assign-elisp:

diff --git i/lisp/ob-R.el w/lisp/ob-R.el
index 6f76aa5..ec3f110 100644
--- i/lisp/ob-R.el
+++ w/lisp/ob-R.el
@@ -239,7 +239,10 @@ This function is called by `org-babel-execute-src-block'."
             (min (if lengths (apply 'min lengths) 0)))
         ;; Ensure VALUE has an orgtbl structure (depth of at least 2).
         (unless (listp (car value)) (setq value (list value)))
-       (let ((file (orgtbl-to-tsv value '(:fmt org-babel-R-quote-tsv-field)))
+       (let ((file (replace-regexp-in-string
+                    "\t" "\\t"
+                    (orgtbl-to-tsv value '(:raw t :fmt org-babel-R-quote-tsv-field))
+                    nil t))
              (header (if (or (eq (nth 1 value) 'hline) colnames-p)
                          "TRUE" "FALSE"))
              (row-names (if rownames-p "1" "NULL")))

(This is just a quick hack; if it works then the code should actually
use orgtbl-to-generic to do the conversion in a single step.)

> ,----
> |   ...  
> |        sep       = \"\",   ;;;;;<<<<<<<<< was before  sep = \"\\t\"
> |   ...
> `----
> 
> This will set the separator to "whitespace", i.e. "that is one or more
> spaces, tabs, newlines or carriage returns" (from R help).

This was the approach that Michael took in his original patch.  It
introduces new bugs related to the handling of quotes, though – see the
“Details” section of ?scan in R for the gory details (beginning with “If
‘sep’ is the default”...).

Andreas raised a bug a while ago that indicates to me that this code
should switch to csv rather than a whitespace-delimited format.  But
there are lots of corner cases, and I have not had time to work on a
patch that I am confident could cover them all.

Andreas’s original report (also referenced earlier in this thread):
http://news.gmane.org/find-root.php?message_id=olulhmmtei5.fsf%40med.uni%2dgoettingen.de

Thanks,

-- 
Aaron Ecay

  reply	other threads:[~2015-01-06 17:49 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-02 19:57 org tables into R? Michael Gauland
2015-01-02 20:13 ` Andreas Leha
2015-01-02 22:45   ` Vikas Rawal
2015-01-04 10:01     ` Andreas Leha
2015-01-05  0:10       ` Aaron Ecay
2015-01-05 11:48         ` Nicolas Goaziou
2015-01-06  4:27           ` Aaron Ecay
2015-01-06 23:08             ` Nicolas Goaziou
2015-01-06 23:17               ` Aaron Ecay
2015-01-06 23:38                 ` Nicolas Goaziou
2015-01-06 10:14           ` Andreas Leha
2015-01-06 11:02             ` Rainer M Krug
2015-01-06 12:07               ` Andreas Leha
2015-01-06 13:37                 ` Rainer M Krug
2015-01-06 17:49                   ` Aaron Ecay [this message]
2015-01-07  9:01                     ` Rainer M Krug
2015-01-04  3:19 ` Michael Gauland

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=87lhlfvly2.fsf@gmail.com \
    --to=aaronecay@gmail.com \
    --cc=Rainer@krugs.de \
    --cc=andreas.leha@med.uni-goettingen.de \
    --cc=emacs-orgmode@gnu.org \
    /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).