Browse Source

now when R blocks return trivial vectors they are converted into scalars

Apparently there are no scalars values in R, scalars are packaged into
vectors, which would result in many single element tables

| scalar |

if we just dropped them straight to emacs-lisp without this conversion
Eric Schulte 16 years ago
parent
commit
9bfd6e0a80
2 changed files with 8 additions and 2 deletions
  1. 7 2
      litorgy/litorgy-R.el
  2. 1 0
      rorg.org

+ 7 - 2
litorgy/litorgy-R.el

@@ -83,8 +83,13 @@ R process in `litorgy-R-buffer'."
       (setq result (mapcar (lambda (row)
                              (mapcar #'litorgy-R-read row))
                            (org-table-to-lisp)))
-      ;; TODO: we may want to scalarize single-element vectors
-      result)))
+      (if (null (cdr result)) ;; if result is trivial vector, then scalarize it
+          (if (consp (car result))
+              (if (null (cdr (car result)))
+                  (caar result)
+                result)
+            (car result))
+        result))))
 
 (defun litorgy-R-read (cell)
   "Strip nested \"s from around strings in exported R values."

+ 1 - 0
rorg.org

@@ -398,6 +398,7 @@ other + 2
 : 11
 
 
+
 * COMMENT Commentary
 I'm seeing this as like commit notes, and a place for less formal
 communication of the goals of our changes.