From: Rainer M Krug <Rainer@krugs.de>
To: Andreas Leha <andreas.leha@med.uni-goettingen.de>
Cc: emacs-orgmode@gnu.org
Subject: Re: org tables into R?
Date: Wed, 07 Jan 2015 10:01:43 +0100 [thread overview]
Message-ID: <m2d26r3qx4.fsf@krugs.de> (raw)
In-Reply-To: <87lhlfvly2.fsf@gmail.com> (Aaron Ecay's message of "Tue, 06 Jan 2015 12:49:25 -0500")
[-- Attachment #1: Type: text/plain, Size: 3258 bytes --]
Aaron Ecay <aaronecay@gmail.com> writes:
> 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.)
That looks like it would work.
>
>> ,----
>> | ...
>> | 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”...).
I agree completely - it would not be a final solution but possibly solve
the problem temporarily in an emacs.org file.
But the real question is: why are on some setups the tabs converted to
spaces?
>
> 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.
Might be a solution - but I do not know how commas are working under
different locales. In MS Office, a csv file is a semicolon (;)
separated file when in the chosen language settings a comma is used as
decimal separator - and and I have no idea if language settings affect
emacs in the same way (I actually don't hope so).
This makes me think - why not use "|" as a separator (as it is the case
in org)? In this way, all tables which are in org can be directly given
to R as strings without the hassle of to much of conversion?
Rainer
>
> 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,
--
Rainer M. Krug
email: Rainer<at>krugs<dot>de
PGP: 0x0F52F982
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 494 bytes --]
next prev parent reply other threads:[~2015-01-07 14:31 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
2015-01-07 9:01 ` Rainer M Krug [this message]
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=m2d26r3qx4.fsf@krugs.de \
--to=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).