ソースを参照

R support partially working assigning variables from R

  still need to figure out how to deal with R tables
Eric Schulte 16 年 前
コミット
3e403fc9bb
3 ファイル変更28 行追加3 行削除
  1. 5 0
      litorgy/litorgy-R.el
  2. 3 1
      litorgy/litorgy.el
  3. 20 2
      rorg.org

+ 5 - 0
litorgy/litorgy-R.el

@@ -40,6 +40,11 @@ called by `litorgy-execute-src-block'."
   (save-window-excursion
     (let ((vars (litorgy-ref-variables params))
           results)
+      (message (format "--%S--" vars))
+      (mapc (lambda (pair)
+              (litorgy-R-input-command
+               (format "%s <- %s" (car pair) (cdr pair))))
+            vars)
       (litorgy-R-initiate-R-buffer)
       (litorgy-R-command-to-string body))))
 

+ 3 - 1
litorgy/litorgy.el

@@ -161,7 +161,9 @@ replace - insert results after the source block replacing any
           previously inserted results
 
 silent -- no results are inserted"
-  (unless (listp result) (setq result (format "%S" result)))
+  (if (stringp result)
+      (setq result (litorgy-clean-text-properties result))
+    (unless (listp result) (setq result (format "%S" result))))
   (if (string-equal insert "replace") (litorgy-remove-result (listp result)))
   (if (= (length result) 0)
       (message "no result returned by source block")

+ 20 - 2
rorg.org

@@ -239,9 +239,11 @@ table
 #+begin_src R :results replace
 a <- 9
 b <- 8
-
+b*a
 #+end_src
 
+: 72
+
 #+begin_src R :results replace
 x <- c(rnorm(10, mean=-3, sd=1), rnorm(10, mean=3, sd=1))
 x
@@ -328,9 +330,11 @@ and for python
 #+end_src
 
 #+begin_src python :var another=start_two :results replace
-another + 3
+another*3
 #+end_src
 
+: 294
+
 *** mixed languages
 Since all variables are converted into Emacs Lisp it is no problem to
 reference variables specified in another language.
@@ -352,6 +356,20 @@ lisp_var + 4
 *** R
 not yet implemented
 
+#+srcname: first_r
+#+begin_src R :results replace
+a <- 9
+a
+#+end_src
+
+: 9
+
+#+begin_src R :var other=first_r :results replace
+other + 2
+#+end_src
+
+: 11
+
 
 * COMMENT Commentary
 I'm seeing this as like commit notes, and a place for less formal