[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] org tables into R?
From: |
Aaron Ecay |
Subject: |
Re: [O] org tables into R? |
Date: |
Tue, 06 Jan 2015 12:49:25 -0500 |
User-agent: |
Notmuch/0.19+11~g3d978a0 (http://notmuchmail.org) Emacs/25.0.50.2 (x86_64-unknown-linux-gnu) |
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
- Re: [O] org tables into R?, (continued)
- Re: [O] org tables into R?, Aaron Ecay, 2015/01/04
- Re: [O] org tables into R?, Nicolas Goaziou, 2015/01/05
- Re: [O] org tables into R?, Aaron Ecay, 2015/01/05
- Re: [O] org tables into R?, Nicolas Goaziou, 2015/01/06
- Re: [O] org tables into R?, Aaron Ecay, 2015/01/06
- Re: [O] org tables into R?, Nicolas Goaziou, 2015/01/06
- Re: [O] org tables into R?, Andreas Leha, 2015/01/06
- Re: [O] org tables into R?, Rainer M Krug, 2015/01/06
- Re: [O] org tables into R?, Andreas Leha, 2015/01/06
- Re: [O] org tables into R?, Rainer M Krug, 2015/01/06
- Re: [O] org tables into R?,
Aaron Ecay <=
- Re: [O] org tables into R?, Rainer M Krug, 2015/01/07
Re: [O] org tables into R?, Michael Gauland, 2015/01/03