summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Ecay <aaronecay@gmail.com>2015-01-23 12:31:33 -0500
committerAaron Ecay <aaronecay@gmail.com>2015-01-23 14:39:30 -0500
commit3996de60dad4f53cb2eae87b901e0f47ba57ada3 (patch)
tree6449628a12597c0eda17e8cbe1b6079f6c7088b2
parentfa5fd6351605912ec75e783cb626497b1ebe471e (diff)
downloadorg-mode-3996de60dad4f53cb2eae87b901e0f47ba57ada3.tar.gz
ob-R: Convert some defvars to defconsts.
* lisp/ob-R.el (org-babel-R-eoe-indicator): (org-babel-R-eoe-output): Convert from defvar to defconst. (org-babel-R-write-object-command): Convert from defvar to defconst. Add line breaks and indentation.
-rw-r--r--lisp/ob-R.el37
1 files changed, 33 insertions, 4 deletions
diff --git a/lisp/ob-R.el b/lisp/ob-R.el
index 2470b4f..639b4f8 100644
--- a/lisp/ob-R.el
+++ b/lisp/ob-R.el
@@ -335,10 +335,39 @@ Each member of this list is a list with three members:
device filearg out-file args
(if extra-args "," "") (or extra-args ""))))
-(defvar org-babel-R-eoe-indicator "'org_babel_R_eoe'")
-(defvar org-babel-R-eoe-output "[1] \"org_babel_R_eoe\"")
-
-(defvar org-babel-R-write-object-command "{function(object,transfer.file){object;invisible(if(inherits(try({tfile<-tempfile();write.table(object,file=tfile,sep=\"\\t\",na=\"nil\",row.names=%s,col.names=%s,quote=FALSE);file.rename(tfile,transfer.file)},silent=TRUE),\"try-error\")){if(!file.exists(transfer.file))file.create(transfer.file)})}}(object=%s,transfer.file=\"%s\")")
+(defconst org-babel-R-eoe-indicator "'org_babel_R_eoe'")
+(defconst org-babel-R-eoe-output "[1] \"org_babel_R_eoe\"")
+
+(defconst org-babel-R-write-object-command "{
+ function(object,transfer.file) {
+ object
+ invisible(
+ if (
+ inherits(
+ try(
+ {
+ tfile<-tempfile()
+ write.table(object, file=tfile, sep=\"\\t\",
+ na=\"nil\",row.names=%s,col.names=%s,
+ quote=FALSE)
+ file.rename(tfile,transfer.file)
+ },
+ silent=TRUE),
+ \"try-error\"))
+ {
+ if(!file.exists(transfer.file))
+ file.create(transfer.file)
+ }
+ )
+ }
+}(object=%s,transfer.file=\"%s\")"
+ "A template for an R command to evaluate a block of code and write the result to a file.
+
+Has four %s escapes to be filled in:
+1. Row names, \"TRUE\" or \"FALSE\"
+2. Column names, \"TRUE\" or \"FALSE\"
+3. The code to be run (must be an expression, not a statement)
+4. The name of the file to write to")
(defun org-babel-R-evaluate
(session body result-type result-params column-names-p row-names-p)