emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [org-babel R] Difference between output in RStudio and in Org Babel
@ 2014-12-10 15:04 Sebastien Vauban
       [not found] ` <87r3w7462j.fsf@gmail.com>
  0 siblings, 1 reply; 2+ messages in thread
From: Sebastien Vauban @ 2014-12-10 15:04 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hello,

I have yet another [1] code chunk that produces very different results
whether it's executed in RStudio or in an Org document.

Here is the code:

#+begin_src R :results value replace :rownames yes :colnames yes
  df.str <- '"liste","nb"
  "item31\nitem80","2"
  "item52","1"'
  df <- read.csv(text=df.str, header = TRUE)
  row.names(df) <- c("abc", "def")
  df
#+end_src

See http://screencast.com/t/qlUVYCoLUZWA for a diff between Org Babel
and RStudio.

Of course, the problem comes from \n being interpreted as a newline, but
who's right here?

Best regards,
  Seb

[1] https://lists.gnu.org/archive/html/emacs-orgmode/2014-10/msg00707.html

-- 
Sebastien Vauban

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [org-babel R] Difference between output in RStudio and in Org Babel
       [not found]   ` <86y4qfgqzr.fsf_-_@example.com>
@ 2014-12-10 21:36     ` Aaron Ecay
  0 siblings, 0 replies; 2+ messages in thread
From: Aaron Ecay @ 2014-12-10 21:36 UTC (permalink / raw)
  To: Sebastien Vauban; +Cc: Org-mode

Hi Seb,

[re-adding the list to cc]

2014ko abenudak 10an, Sebastien Vauban-ek idatzi zuen:
>
> FYI, the link is a screen capture image, in this case, not a video!

OK, now I feel sheepish.  I assumed from the screencast.com URL that
there was intended to be some video, for which the image displayed was
just the (first/last/etc.) frame.  Now I understand better.


> With my example, what I expect is:
> 
>  |     | liste          | nb |
>  |-----+----------------+----|
>  | abc | item31\nitem80 |  2 |
>  | def | item52         |  1 |

There’s no convention in org tables that “\n” (i.e. two characters,
backslash + n) means newline (i.e. one character).

> In this case, I'd expect the same as in RStudio; that is, no multi-line
> cell, but simply a cell with a string in it -- which, yes, does contain
> the \n character:

What R’s console shows you (either RStudio or vanilla R) is a “human
readable” representation of the data frame, which includes doing
things like changing the newline character into a \n escape sequence
(and other stuff, like padding the columns with spaces so they all
line up vertically).  But when Org communicates with R, it asks for a
machine-readable version, which doesn’t include such niceties.  When
that machine-readable version includes a newline character in a data
field (as your example table does), org doesn’t know what to do and
messes up.

-- 
Aaron Ecay

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-12-10 21:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-10 15:04 [org-babel R] Difference between output in RStudio and in Org Babel Sebastien Vauban
     [not found] ` <87r3w7462j.fsf@gmail.com>
     [not found]   ` <86y4qfgqzr.fsf_-_@example.com>
2014-12-10 21:36     ` Aaron Ecay

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).