forked from mirrors/org-mode
Revert "Make org table result have header row and hline when appropriate..."
This reverts commit e4263daf76
.
I'm reverting this commit in the sesion branch because it is breaking
the tests for R, as it no longer allows R source code blocks to return
scalar values. Hopefully this issue will be fixed in the master
branch before I merge the session branch back in.
This commit is contained in:
parent
517253a2d0
commit
dff01091dc
|
@ -79,18 +79,18 @@ R process in `org-babel-R-buffer'."
|
||||||
`org-babel-R-buffer' as Emacs lisp."
|
`org-babel-R-buffer' as Emacs lisp."
|
||||||
(let ((tmp-file (make-temp-file "org-babel-R")) result)
|
(let ((tmp-file (make-temp-file "org-babel-R")) result)
|
||||||
(org-babel-R-input-command
|
(org-babel-R-input-command
|
||||||
(format "write.table(%s(), file=\"%s\", sep=\"\\t\", na=\"nil\",row.names=FALSE, col.names=TRUE, quote=FALSE)"
|
(format "write.table(%s(), \"%s\", , ,\"\\t\", ,\"nil\", , FALSE, FALSE)" func-name tmp-file))
|
||||||
func-name tmp-file))
|
|
||||||
(with-temp-buffer
|
(with-temp-buffer
|
||||||
|
(message "before condition")
|
||||||
(condition-case nil
|
(condition-case nil
|
||||||
(progn
|
(progn
|
||||||
(org-table-import tmp-file nil)
|
(org-table-import tmp-file nil)
|
||||||
(delete-file tmp-file)
|
(delete-file tmp-file)
|
||||||
(setq result (mapcar (lambda (row)
|
(setq result (mapcar (lambda (row)
|
||||||
(mapcar #'org-babel-R-read row))
|
(mapcar #'org-babel-R-read row))
|
||||||
(org-table-to-lisp)))
|
(org-table-to-lisp))))
|
||||||
(setq result (org-babel-R-set-header-row result)))
|
|
||||||
(error nil))
|
(error nil))
|
||||||
|
(message "after condition")
|
||||||
(if (null (cdr result)) ;; if result is trivial vector, then scalarize it
|
(if (null (cdr result)) ;; if result is trivial vector, then scalarize it
|
||||||
(if (consp (car result))
|
(if (consp (car result))
|
||||||
(if (null (cdr (car result)))
|
(if (null (cdr (car result)))
|
||||||
|
@ -99,20 +99,6 @@ R process in `org-babel-R-buffer'."
|
||||||
(car result))
|
(car result))
|
||||||
result))))
|
result))))
|
||||||
|
|
||||||
(defun org-babel-R-set-header-row (table)
|
|
||||||
"Check whether the table appears to have (a) genuine
|
|
||||||
user-supplied column names, or (b) default column names added
|
|
||||||
automatically by R. In case (a), maintain the first row of the
|
|
||||||
table as a header row and insert an hline. In case (b), remove
|
|
||||||
the first row and return the org table without an hline."
|
|
||||||
(if (string-equal (caar table) "V1")
|
|
||||||
;; The first row looks like it contains default column names
|
|
||||||
;; added by R. This condition could be improved so that it
|
|
||||||
;; checks whether the first row is ("V1" "V2" ... "V$n") where
|
|
||||||
;; $n is the number of columns.
|
|
||||||
(cdr table)
|
|
||||||
(cons (car table) (cons 'hline (cdr table)))))
|
|
||||||
|
|
||||||
(defun org-babel-R-read (cell)
|
(defun org-babel-R-read (cell)
|
||||||
"Strip nested \"s from around strings in exported R values."
|
"Strip nested \"s from around strings in exported R values."
|
||||||
(org-babel-read (or (and (stringp cell)
|
(org-babel-read (or (and (stringp cell)
|
||||||
|
|
Loading…
Reference in a new issue