|
@@ -97,24 +97,15 @@ this variable.")
|
|
|
"Expand BODY according to PARAMS, return the expanded body."
|
|
|
(let ((graphics-file
|
|
|
(or graphics-file (org-babel-R-graphical-output-file params))))
|
|
|
- (mapconcat
|
|
|
- #'identity
|
|
|
- (let ((inside
|
|
|
- (append
|
|
|
- (when (cdr (assoc :prologue params))
|
|
|
- (list (cdr (assoc :prologue params))))
|
|
|
- (org-babel-variable-assignments:R params)
|
|
|
- (list body)
|
|
|
- (when (cdr (assoc :epilogue params))
|
|
|
- (list (cdr (assoc :epilogue params)))))))
|
|
|
- (if graphics-file
|
|
|
- (append
|
|
|
- (list (org-babel-R-construct-graphics-device-call
|
|
|
- graphics-file params))
|
|
|
- inside
|
|
|
- (list "},error=function(e){plot(x=-1:1, y=-1:1, type='n', xlab='', ylab='', axes=FALSE); text(x=0, y=0, labels=e$message, col='red'); paste('ERROR', e$message, sep=' : ')}); dev.off()"))
|
|
|
- inside))
|
|
|
- "\n")))
|
|
|
+ (mapconcat #'identity
|
|
|
+ (append
|
|
|
+ (when (cdr (assoc :prologue params))
|
|
|
+ (list (cdr (assoc :prologue params))))
|
|
|
+ (org-babel-variable-assignments:R params)
|
|
|
+ (list body)
|
|
|
+ (when (cdr (assoc :epilogue params))
|
|
|
+ (list (cdr (assoc :epilogue params)))))
|
|
|
+ "\n")))
|
|
|
|
|
|
(defun org-babel-execute:R (body params)
|
|
|
"Execute a block of R code.
|
|
@@ -127,7 +118,18 @@ This function is called by `org-babel-execute-src-block'."
|
|
|
(colnames-p (cdr (assoc :colnames params)))
|
|
|
(rownames-p (cdr (assoc :rownames params)))
|
|
|
(graphics-file (org-babel-R-graphical-output-file params))
|
|
|
- (full-body (org-babel-expand-body:R body params graphics-file))
|
|
|
+ (full-body
|
|
|
+ (let ((inside
|
|
|
+ (list (org-babel-expand-body:R body params graphics-file))))
|
|
|
+ (mapconcat #'identity
|
|
|
+ (if graphics-file
|
|
|
+ (append
|
|
|
+ (list (org-babel-R-construct-graphics-device-call
|
|
|
+ graphics-file params))
|
|
|
+ inside
|
|
|
+ (list "},error=function(e){plot(x=-1:1, y=-1:1, type='n', xlab='', ylab='', axes=FALSE); text(x=0, y=0, labels=e$message, col='red'); paste('ERROR', e$message, sep=' : ')}); dev.off()"))
|
|
|
+ inside)
|
|
|
+ "\n")))
|
|
|
(result
|
|
|
(org-babel-R-evaluate
|
|
|
session full-body result-type result-params
|