emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] org tables into R?


From: Andreas Leha
Subject: Re: [O] org tables into R?
Date: Tue, 06 Jan 2015 10:14:30 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (darwin)

Hi Aaron and Nicolas,

Thanks for partly fixing this issue.  Unfortunately, when working with
source block interactively the issue persists for me.  If in the same
sample file I view the source block via 'C-c C-v v' and step through the
generated code line-by-line, the table is again not split into columns.

This time I immediately tried with 'emacs -Q' and I can reproduce the
issue.

Here is the ecm again:

--8<---------------cut here---------------start------------->8---
* test
#+NAME: data
|   A |  B |  C |
|-----+----+----|
| 115 | 76 | 60 |
| 124 | 78 | 55 |
| 118 | 73 | 65 |
| 114 | 75 | 61 |
| 108 | 74 | 82 |

and pass it into R like this, then evaluation (C-c C-c) works, but
stepping through the code generated for viewing (C-c C-v v) does not:

#+BEGIN_SRC R :results output :exports both :session :var data.table=data
  names(data.table)
  head(data.table)
#+END_SRC

#+results:
: [1] "A" "B" "C"
:     A  B  C
: 1 115 76 60
: 2 124 78 55
: 3 118 73 65
: 4 114 75 61
: 5 108 74 82

#+begin_src emacs-lisp
  (concat
   (replace-regexp-in-string " on .*" "" (emacs-version))
   "\n"
   (replace-regexp-in-string " @.*" ")" (org-version nil t))
   "\n"
   (replace-regexp-in-string "].*" "]" (ess-version)))
#+end_src

#+results:
: GNU Emacs 24.4.50.1 (x86_64-apple-darwin13.3.0, NS appkit-1265.21 Version 
10.9.4 (Build 13E28))
:  of 2014-09-02
: Org-mode version 8.3beta (release_8.3beta-717-ga8096c)
: ess-version: 14.05 [git: 4283f1304a54502c42707b6a4ba347703f0992dd]
--8<---------------cut here---------------end--------------->8---


Here is what I see in the org babel preview:

--8<---------------cut here---------------start------------->8---
data.table <- local({
     con <- textConnection(
       "\"A\"   \"B\"   \"C\"
\"115\" \"76\"  \"60\"
\"124\" \"78\"  \"55\"
\"118\" \"73\"  \"65\"
\"114\" \"75\"  \"61\"
\"108\" \"74\"  \"82\""
     )
     res <- utils::read.table(
       con,
       header    = TRUE,
       row.names = NULL,
       sep       = "\t",
       as.is     = TRUE
     )
     close(con)
     res
   })
names(data.table)
head(data.table)
--8<---------------cut here---------------end--------------->8---


And finally, here is my R session, when I step through the code:

--8<---------------cut here---------------start------------->8---

R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet"
Copyright (C) 2014 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin10.8.0 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> > options(STERM='iESS', str.dendrogram.last="'", editor='emacsclient', 
> > show.error.locations=TRUE)
> data.table <- local({
+      con <- textConnection(
+        "\"A\"   \"B\"   \"C\"
+ \"115\" \"76\"  \"60\"
+ \"124\" \"78\"  \"55\"
+ \"118\" \"73\"  \"65\"
+ \"114\" \"75\"  \"61\"
+ \"108\" \"74\"  \"82\""
+      )
+      res <- utils::read.table(
+        con,
+        header    = TRUE,
+        row.names = NULL,
+        sep       = "\t",
+        as.is     = TRUE
+      )
+      close(con)
+      res
+    })
> names(data.table)
[1] "A...B...C"
> head(data.table)
   A...B...C
1 115 76  60
2 124 78  55
3 118 73  65
4 114 75  61
5 108 74  82
--8<---------------cut here---------------end--------------->8---


Regards,
Andreas




reply via email to

[Prev in Thread] Current Thread [Next in Thread]