;ELC ;;; Compiled ;;; in Emacs version 26.3 ;;; with all optimizations. ;;; This file uses dynamic docstrings, first added in Emacs 19.29. ;;; This file does not contain utf-8 non-ASCII characters, ;;; and so can be loaded in Emacs versions earlier than 23. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (byte-code "\300\301!\210\300\302!\207" [require cl-lib ob] 2) #@30 R-specific header arguments. (defconst org-babel-header-args:R '((width . :any) (height . :any) (bg . :any) (units . :any) (pointsize . :any) (antialias . :any) (quality . :any) (compression . :any) (res . :any) (type . :any) (family . :any) (title . :any) (fonts . :any) (version . :any) (paper . :any) (encoding . :any) (pagecentre . :any) (colormodel . :any) (useDingbats . :any) (horizontal . :any) (results (file list vector table scalar verbatim) (raw html latex org code pp drawer) (replace silent none append prepend) (output value graphics))) (#$ . 471)) #@132 Header args which are safe for R babel blocks. See `org-babel-safe-header-args' for documentation of the format of this variable. (defconst ob-R-safe-header-args (append org-babel-safe-header-args '(:width :height :bg :units :pointsize :antialias :quality :compression :res :type :family :title :fonts :version :paper :encoding :pagecentre :colormodel :useDingbats :horizontal)) (#$ . 1042)) (defvar org-babel-default-header-args:R nil) (byte-code "\300\301\302\303#\210\304\305\306\307\310DD\311\312\313\314\315\316\317& \207" [put org-babel-default-header-args:R safe-local-variable #[257 "\211<\205 \300\301\"\207" [cl-every #[257 "\211:\205 \301\"\207" [ob-R-safe-header-args org-babel-one-header-arg-safe-p] 4 "\n\n(fn PAIR)"]] 4 "\n\n(fn VALUE)"] custom-declare-variable org-babel-R-command funcall function #[0 "\300\207" [#1="R --slave --no-save"] 1 #1#] "Name of command to use for executing R code." :group org-babel :version "24.1" :type string] 10) #@13 (fn INFO) (defalias 'org-babel-edit-prep:R #[257 "\300\3018\236A\211\205\302\303\"\205\304\303\"\205\305\306\"\207" [:session 2 string-prefix-p "*" string-suffix-p org-babel-R-initiate-session nil] 5 (#$ . 2015)]) #@127 R code used to transfer a table defined as a variable from org to R. This function is used when the table contains a header. (defconst ob-R-transfer-variable-table-with-header "%s <- local({\n con <- textConnection(\n %S\n )\n res <- utils::read.table(\n con,\n header = %s,\n row.names = %s,\n sep = \"\\t\",\n as.is = TRUE\n )\n close(con)\n res\n })" (#$ . 2248)) #@135 R code used to transfer a table defined as a variable from org to R. This function is used when the table does not contain a header. (defconst ob-R-transfer-variable-table-without-header "%s <- local({\n con <- textConnection(\n %S\n )\n res <- utils::read.table(\n con,\n header = %s,\n row.names = %s,\n sep = \"\\t\",\n as.is = TRUE,\n fill = TRUE,\n col.names = paste(\"V\", seq_len(%d), sep =\"\")\n )\n close(con)\n res\n })" (#$ . 2698)) #@102 Expand BODY according to PARAMS, return the expanded body. (fn BODY PARAMS &optional GRAPHICS-FILE) (defalias 'org-babel-expand-body:R #[770 "\300\301\302\303\236A\205\303\236AC\304!C\305\236A\205$\305\236AC$\306#\207" [mapconcat identity append :prologue org-babel-variable-assignments:R :epilogue "\n"] 11 (#$ . 3243)]) #@104 Execute a block of R code. This function is called by `org-babel-execute-src-block'. (fn BODY PARAMS) (defalias 'org-babel-execute:R #[514 "\212\300\236A\301\236A\302\303\236A\"\304\300\236\235\205\305!\211?\205$\306\236A?\205.\307\236A\310#C\311\312\203K\313\314\f\"C\315C#\202L\316#\262\317\n\320\232\206g\321\322\236A \"\320\232\206w\321\323\236A \"&?\205\211\266\210)\207" [:result-params :result-type org-babel-R-initiate-session :session "graphics" org-babel-graphical-output-file :colnames :rownames org-babel-expand-body:R mapconcat identity append org-babel-R-construct-graphics-device-call "},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()" "\n" org-babel-R-evaluate "yes" org-babel-pick-name :colname-names :rowname-names] 18 (#$ . 3586)]) #@93 Prepare SESSION according to the header arguments specified in PARAMS. (fn SESSION PARAMS) (defalias 'org-babel-prep-session:R #[514 "\301\"\302!\303!\204\304\305\"\210\306 \307\310\311\312\313!\314\"\315$\216rq\210\212\316\317\307\320\321\312\313!\322\"\323\324%\"\210,\210\207" [comint-input-filter org-babel-R-initiate-session org-babel-variable-assignments:R org-babel-comint-buffer-livep error "Buffer %s does not exist or has no process" match-data make-byte-code 0 "\301\300\302\"\207" vconcat vector [set-match-data evaporate] 3 #[257 "\300\207" [nil] 2 "\n\n(fn INPUT)"] mapc 257 "\301\210\211c\210\302\303\304\"\210\305\300!\207" [1 comint-send-input nil t org-babel-comint-wait-for-output] 4 "\n\n(fn VAR)"] 12 (#$ . 4521)]) #@51 Load BODY into SESSION. (fn SESSION BODY PARAMS) (defalias 'org-babel-load-session:R #[771 "\300 \301\302\303\304\305!\306\"\307$\216\310\"r\211q\210\311\312p!!b\210\313!c\210)\211\262)\207" [current-window-configuration make-byte-code 0 "\301\300!\207" vconcat vector [set-window-configuration] 2 org-babel-prep-session:R process-mark get-buffer-process org-babel-chomp] 10 (#$ . 5279)]) #@75 Return list of R statements assigning the block's variables. (fn PARAMS) (defalias 'org-babel-variable-assignments:R #[257 "\300!\301\302\303\304\305\306!\307\"\310\311%\301\302\303\312\305\306  \"\313\"\314\315%\316\317GS\"\"\"\207" [org-babel--get-vars mapcar make-byte-code 257 "\301@A\302\300\236A\303\232\304\300\236A\303\232$\207" vconcat vector [org-babel-R-assign-elisp :colnames "yes" :rownames] 7 "\n\n(fn PAIR)" "\211\3018@\302\3018A\303\300\236A8A\304\300\236A8A#B\207" [org-babel-reassemble-table :colname-names :rowname-names] 8 "\n\n(fn I)" number-sequence 0] 12 (#$ . 5680)]) #@40 Quote field S for export to R. (fn S) (defalias 'org-babel-R-quote-tsv-field #[257 "\211;\203\300\301\302\303\300\"\304#\300Q\207\305\306\"\207" ["\"" mapconcat identity split-string "\"\"" format "%S"] 7 (#$ . 6291)]) #@109 Construct R code assigning the elisp VALUE to a variable named NAME. (fn NAME VALUE COLNAMES-P ROWNAMES-P) (defalias 'org-babel-R-assign-elisp #[1028 "<\203n\303\304\305\306\"\"\211\203\307\310\"\202\311\203$\307\312\"\202%\311@<\204/C\262\313\314\"A@\315=\204A\203E\316\202F\317\203N\320\202O\321U\203`\322 %\202k\322  \n&\266\203\207\250\203~\322\323\324!\325P#\207\326!\203\212\322\323#\207;\203\260\322\327\330\211\203\243\331\311G\n$\210\202\253\332\311G\330$\210\266\202#\207\322\327\333!#\207" [ob-R-transfer-variable-table-with-header ob-R-transfer-variable-table-without-header org-rm-props mapcar length cl-remove-if-not sequencep apply max 0 min orgtbl-to-tsv (:fmt org-babel-R-quote-tsv-field) hline "TRUE" "FALSE" "1" "NULL" format "%s <- %s" number-to-string "L" floatp "%s <- %S" nil remove-text-properties set-text-properties prin1-to-string] 17 (#$ . 6522)]) #@75 If there is not a current R process then create one. (fn SESSION PARAMS) (defalias 'org-babel-R-initiate-session #[514 "\303\230?\205{\206\f\304\305\300!\205\205\306\236A?\307!\203&\211\202x\310 \311\312\313\314\315!\316\"\317$\216\320!\203=q\210\321\322!\210\323 \210\324 \206J\n!\325\326\"\203Y\327!\210\202K\210\330\331!\203g\332!\202r;\203p\202r\332 !\210p)\262)\262\207" [ess-ask-for-ess-directory ess-local-process-name ess-current-process-name "none" "*R*" boundp :dir org-babel-comint-buffer-livep current-window-configuration make-byte-code 0 "\301\300!\207" vconcat vector [set-window-configuration] 2 get-buffer require ess R get-process process-get callbacks ess-wait-for-process rename-buffer bufferp buffer-name] 10 (#$ . 7471)]) #@140 Associate R code buffer with an R session. Make SESSION be the inferior ESS process associated with the current code buffer. (fn SESSION) (defalias 'org-babel-R-associate-session #[257 "\301\302!!\303 \207" [ess-local-process-name process-name get-buffer-process ess-make-buffer-current] 4 (#$ . 8256)]) #@359 An alist mapping graphics file types to R functions. Each member of this list is a list with three members: 1. the file extension of the graphics file, as an elisp :keyword 2. the R graphics device function to call to generate such a file 3. the name of the argument to this function which specifies the file to write to (typically "file" or "filename") (defvar org-babel-R-graphics-devices '((:bmp "bmp" "filename") (:jpg "jpeg" "filename") (:jpeg "jpeg" "filename") (:tikz "tikz" "file") (:tiff "tiff" "filename") (:png "png" "filename") (:svg "svg" "file") (:pdf "pdf" "file") (:ps "postscript" "file") (:postscript "postscript" "file")) (#$ . 8570)) #@66 Construct the call to the graphics device. (fn OUT-FILE PARAMS) (defalias 'org-babel-R-construct-graphics-device-call #[514 "\301\302!\303\304P!\236\206\305\236\306\236A\307\211A@\262\3108\262\311\312\313\314\315\316 !\317\"\320\321%\322#\262\323\324 \203F\325\202G\322 \206M\322&\207" [org-babel-R-graphics-devices (:width :height :bg :units :pointsize :antialias :quality :compression :res :type :family :title :fonts :version :paper :encoding :pagecentre :colormodel :useDingbats :horizontal) file-name-extension intern ":" :png :R-dev-args nil 2 mapconcat make-byte-code 257 "\211@\300\235\203\301\302\303@!\304\305OA#\207\306\207" vconcat vector [format ",%s=%S" symbol-name 1 nil #1=""] 6 "\n\n(fn PAIR)" #1# format "%s(%s=\"%s\"%s%s%s); tryCatch({" ","] 16 (#$ . 9234)]) (defconst org-babel-R-eoe-indicator "'org_babel_R_eoe'") (defconst org-babel-R-eoe-output "[1] \"org_babel_R_eoe\"") #@293 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 (defconst org-babel-R-write-object-command "{\n function(object,transfer.file) {\n object\n invisible(\n if (\n inherits(\n try(\n {\n tfile<-tempfile()\n write.table(object, file=tfile, sep=\"\\t\",\n na=\"nil\",row.names=%s,col.names=%s,\n quote=FALSE)\n file.rename(tfile,transfer.file)\n },\n silent=TRUE),\n \"try-error\"))\n {\n if(!file.exists(transfer.file))\n file.create(transfer.file)\n }\n )\n }\n}(object=%s,transfer.file=\"%s\")" (#$ . 10168)) #@98 Evaluate R code in BODY. (fn SESSION BODY RESULT-TYPE RESULT-PARAMS COLUMN-NAMES-P ROW-NAMES-P) (defalias 'org-babel-R-evaluate #[1542 "\203\300&\207\301%\207" [org-babel-R-evaluate-session org-babel-R-evaluate-external-process] 13 (#$ . 11319)]) #@268 Evaluate BODY in external R process. If RESULT-TYPE equals `output' then return standard output as a string. If RESULT-TYPE equals `value' then return the value of the last statement in BODY, as elisp. (fn BODY RESULT-TYPE RESULT-PARAMS COLUMN-NAMES-P ROW-NAMES-P) (defalias 'org-babel-R-evaluate-external-process #[1285 "\302\303\"\203\255\304\305!\306\307 \203\310\202\311\203)\203%\312\202*\310\202*\311\307\313 \"\314\315\"%\"\210\316\317\235?\205\250\320\235\204\202\321\235\204\202\322\235\204\202\323\235\204\202\324\235\204\202\325\235\204\202\326\235\204|\327\235\204|\330\235\204|\331\235\203\244\332\235\204\244\333\334!r\211q\210\335\336\337\340\341!\342\"\343$\216\344!\210\345\346 \347\"*\262\202\250\350\351\"\262\"\207\302\352\"\205\271\306\"\207" [org-babel-R-command org-babel-R-write-object-command eql value org-babel-temp-file "R-" org-babel-eval format "TRUE" "FALSE" "NA" "{function ()\n{\n%s\n}}()" org-babel-process-file-name noquote org-babel-R-process-value-result "none" "scalar" "verbatim" "html" "code" "pp" "file" "output" "raw" "org" "drawer" "table" generate-new-buffer " *temp*" make-byte-code 0 "\301\300!\205 \302\300!\207" vconcat vector [buffer-name kill-buffer] 2 insert-file-contents org-babel-chomp buffer-string "\n" org-babel-import-elisp-from-file (16) output] 16 (#$ . 11595)]) #@265 Evaluate BODY in SESSION. If RESULT-TYPE equals `output' then return standard output as a string. If RESULT-TYPE equals `value' then return the value of the last statement in BODY, as elisp. (fn SESSION BODY RESULT-TYPE RESULT-PARAMS COLUMN-NAMES-P ROW-NAMES-P) (defalias 'org-babel-R-evaluate-session #[1542 "\306\307\"\203\324\310\311!r\211q\210\312\313\314\315\316!\317\"\320$\216\321!c\210\322\323!!\324\325\324!\210,\210\326\327!\330\331\n\203A\332\202B\333\203T\203P\334\202U\332\202U\333\335\336 \337\"%#\210\340\341\235?\205\317\342\235\204\251\343\235\204\251\344\235\204\251\345\235\204\251\346\235\204\251\347\235\204\251\350\235\204\243\351\235\204\243\352\235\204\243\353\235\203\313\354\235\204\313\310\311!r\211q\210\312\313\314\315\316!\355\"\320$\216\356!\210\321\357 \360\"*\262\202\317\361\362\"\262\"\207\306\363\"\205\234\364\321\365\366\324\367\370\367\371\372!\204\361\373\374\"\210\375 \312\313\376\315\316!\377\"\201C$\216rq\210\212\201D\201EC\312\201F\201G\315\316!\201H\"\201I\201J%\fB\324\201K\323p!!b\210`d{\262|\266\364\321 D\360#c\210\201L \210@b\210\212\201M\201NA!\324\201O#\205m\201MB\324\201O#)\204|\201P\323p!!\210\202M\201K\323p!!b\210\211c\210\201Q\242B\")\266\202,\262\"\"\"!\360#\207" [ess-eval-visibly-p ess-local-process-name org-babel-R-write-object-command comint-input-filter comint-output-filter-functions org-babel-R-eoe-indicator eql value generate-new-buffer " *temp*" make-byte-code 0 "\301\300!\205 \302\300!\207" vconcat vector [buffer-name kill-buffer] 2 org-babel-chomp process-name get-buffer-process nil ess-eval-buffer org-babel-temp-file "R-" org-babel-comint-eval-invisibly-and-wait-for-file format "TRUE" "FALSE" "NA" ".Last.value" org-babel-process-file-name noquote org-babel-R-process-value-result "none" "scalar" "verbatim" "html" "code" "pp" "file" "output" "raw" "org" "drawer" "table" [buffer-name kill-buffer] insert-file-contents buffer-string "\n" org-babel-import-elisp-from-file (16) output mapconcat butlast delq mapcar #[257 "\211G\300V\205\211\207" [0] 3 "\n\n(fn LINE)"] #[257 "\300\301\302\303\"@\"\203\211\304\225\305O\207\207" [string-match "^\\([>+.]\\([ ][>.+]\\)*[ ]\\)" split-string "\n" 1 nil] 6 "\n\n(fn LINE)"] org-babel-comint-buffer-livep error "Buffer %s does not exist or has no process" match-data "\301\300\302\"\207" [set-match-data evaporate] comint-last-input-end org-babel-R-eoe-output comint-prompt-regexp 3 #[257 "\300\207" [nil] 2 "\n\n(fn INPUT)"] "" 257 "\300\211\242P\240\207" [] 4 "\n\n(fn TEXT)" process-mark inferior-ess-send-input re-search-forward regexp-quote t accept-process-output split-string] 23 (#$ . 12984)]) #@128 R-specific processing of return value. Insert hline if column names in output have been requested. (fn RESULT COLUMN-NAMES-P) (defalias 'org-babel-R-process-value-result #[514 "\211\203\3001@\301ABB0\207\210\302\207\207" [(error) hline "Could not parse R result"] 5 (#$ . 15729)]) (provide 'ob-R)