lisp/ob-R.el: Fix tangling with tables
* lisp/ob-R.el (org-babel-R-assign-elisp): Fix variable transfer of tables by using text connections in R instead of files. Variable transfer of tables does not depend on files anymore, i.e. works also when tangling.
This commit is contained in:
parent
da8b695b2b
commit
fdfb59454a
52
lisp/ob-R.el
52
lisp/ob-R.el
|
@ -190,32 +190,44 @@ This function is called by `org-babel-execute-src-block'."
|
|||
(if (listp value)
|
||||
(let* ((lengths (mapcar 'length (org-remove-if-not 'sequencep value)))
|
||||
(max (if lengths (apply 'max lengths) 0))
|
||||
(min (if lengths (apply 'min lengths) 0))
|
||||
(transition-file (org-babel-temp-file "R-import-")))
|
||||
(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)))
|
||||
(with-temp-file transition-file
|
||||
(insert
|
||||
(orgtbl-to-tsv value '(:fmt org-babel-R-quote-tsv-field))
|
||||
"\n"))
|
||||
(let ((file (org-babel-process-file-name transition-file 'noquote))
|
||||
(let ((file (orgtbl-to-tsv value '(:fmt org-babel-R-quote-tsv-field)))
|
||||
(header (if (or (eq (nth 1 value) 'hline) colnames-p)
|
||||
"TRUE" "FALSE"))
|
||||
(row-names (if rownames-p "1" "NULL")))
|
||||
(if (= max min)
|
||||
(format "%s <- read.table(\"%s\",
|
||||
header=%s,
|
||||
row.names=%s,
|
||||
sep=\"\\t\",
|
||||
as.is=TRUE)" name file header row-names)
|
||||
(format "%s <- read.table(\"%s\",
|
||||
header=%s,
|
||||
row.names=%s,
|
||||
sep=\"\\t\",
|
||||
as.is=TRUE,
|
||||
fill=TRUE,
|
||||
col.names = paste(\"V\", seq_len(%d), sep =\"\"))"
|
||||
name file header row-names max))))
|
||||
(format "%s <- local({
|
||||
con <- textConnection(
|
||||
%S
|
||||
)
|
||||
res <- read.table(
|
||||
con,
|
||||
header = %s,
|
||||
row.names = %s,
|
||||
sep = \"\\t\",
|
||||
as.is = TRUE
|
||||
)
|
||||
close(con)
|
||||
res
|
||||
})" name file header row-names)
|
||||
(format "%s <- local({
|
||||
con <- textConnection(
|
||||
%S
|
||||
)
|
||||
res <- read.table(
|
||||
con,
|
||||
header = %s,
|
||||
row.names = %s,
|
||||
sep = \"\\t\",
|
||||
as.is = TRUE,
|
||||
fill = TRUE,
|
||||
col.names = paste(\"V\", seq_len(%d), sep =\"\")
|
||||
)
|
||||
close(con)
|
||||
res
|
||||
})" name file header row-names max))))
|
||||
(format "%s <- %s" name (org-babel-R-quote-tsv-field value))))
|
||||
|
||||
(defvar ess-ask-for-ess-directory) ; dynamically scoped
|
||||
|
|
Loading…
Reference in New Issue