Browse Source

R support partially working assigning variables from R

  still need to figure out how to deal with R tables
Eric Schulte 16 years ago
parent
commit
3e403fc9bb
3 changed files with 28 additions and 3 deletions
  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
   (save-window-excursion
     (let ((vars (litorgy-ref-variables params))
     (let ((vars (litorgy-ref-variables params))
           results)
           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-initiate-R-buffer)
       (litorgy-R-command-to-string body))))
       (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
           previously inserted results
 
 
 silent -- no results are inserted"
 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 (string-equal insert "replace") (litorgy-remove-result (listp result)))
   (if (= (length result) 0)
   (if (= (length result) 0)
       (message "no result returned by source block")
       (message "no result returned by source block")

+ 20 - 2
rorg.org

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