* was this intentional with the default header ":results value"
@ 2012-07-13 14:24 Eric Luo
2012-07-14 16:44 ` Thomas S. Dye
0 siblings, 1 reply; 6+ messages in thread
From: Eric Luo @ 2012-07-13 14:24 UTC (permalink / raw)
To: emacs-orgmode
Hi,
Why in the following code block, c1 was printed as scientific notation
rather then characters.
,----
|
| #+BEGIN_SRC R :results value
| df <- data.frame(c1="123456789123456789",c2=2)
| #+END_SRC
|
| #+RESULTS:
| | 1.2345678912345678e+17 | 2 |
`----
But if the header :results output, the result was expected.
,----
|
| #+BEGIN_SRC R :results output
| df <- data.frame(c1="123456789123456789",c2=2)
| df
| #+END_SRC
|
| #+RESULTS:
| : c1 c2
| : 1 123456789123456789 2
`----
Thanks
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: was this intentional with the default header ":results value"
2012-07-13 14:24 was this intentional with the default header ":results value" Eric Luo
@ 2012-07-14 16:44 ` Thomas S. Dye
2012-07-15 1:00 ` Eric Luo
0 siblings, 1 reply; 6+ messages in thread
From: Thomas S. Dye @ 2012-07-14 16:44 UTC (permalink / raw)
To: Eric Luo; +Cc: emacs-orgmode
Aloha Eric,
Eric Luo <eric.wenbl@gmail.com> writes:
> Hi,
> Why in the following code block, c1 was printed as scientific notation
> rather then characters.
> ,----
> |
> | #+BEGIN_SRC R :results value
> | df <- data.frame(c1="123456789123456789",c2=2)
> | #+END_SRC
> |
> | #+RESULTS:
> | | 1.2345678912345678e+17 | 2 |
> `----
With :results value the results are passed from the source language into
emacs-lisp and then displayed in the buffer. So, the representation of
things like very large numbers depends on how that was done in
emacs-lisp, independent of the source language conventions. In this
case, I suspect the number was written with a formatting string and ‘%g’
which uses scientific notation if that is a shorter representation.
> But if the header :results output, the result was expected.
> ,----
> |
> | #+BEGIN_SRC R :results output
> | df <- data.frame(c1="123456789123456789",c2=2)
> | df
> | #+END_SRC
> |
> | #+RESULTS:
> | : c1 c2
> | : 1 123456789123456789 2
> `----
>
With :results output the results aren't translated into emacs-lisp.
Instead, the output from the source language is collected and displayed
in the buffer. Thus, the output conventions of the source language are
respected.
hth,
Tom
--
Thomas S. Dye
http://www.tsdye.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: was this intentional with the default header ":results value"
2012-07-14 16:44 ` Thomas S. Dye
@ 2012-07-15 1:00 ` Eric Luo
2012-07-15 3:33 ` Thomas S. Dye
0 siblings, 1 reply; 6+ messages in thread
From: Eric Luo @ 2012-07-15 1:00 UTC (permalink / raw)
To: emacs-orgmode
tsd@tsdye.com (Thomas S. Dye) writes:
Thanks, it's clear to me with the difference between "value" and
"output" now.
whether there is a way to tell emacs-lisp that "123456789123456789" is a
string rather than a number.
emacs-lisp handles the output as expected if the c1 has any character
other than numbers as the following.
,----
| #+BEGIN_SRC R
| df <- data.frame(c1="c123456789123456789",c2=2)
| df$c1 <- as.vector(df$c1)
| df
| #+END_SRC
|
| #+RESULTS:
| | c123456789123456789 | 2 |
|
`----
> Aloha Eric,
>
> Eric Luo <eric.wenbl@gmail.com> writes:
>
>> Hi,
>> Why in the following code block, c1 was printed as scientific notation
>> rather then characters.
>> ,----
>> |
>> | #+BEGIN_SRC R :results value
>> | df <- data.frame(c1="123456789123456789",c2=2)
>> | #+END_SRC
>> |
>> | #+RESULTS:
>> | | 1.2345678912345678e+17 | 2 |
>> `----
>
> With :results value the results are passed from the source language into
> emacs-lisp and then displayed in the buffer. So, the representation of
> things like very large numbers depends on how that was done in
> emacs-lisp, independent of the source language conventions. In this
> case, I suspect the number was written with a formatting string and ‘%g’
> which uses scientific notation if that is a shorter representation.
>
>
>> But if the header :results output, the result was expected.
>> ,----
>> |
>> | #+BEGIN_SRC R :results output
>> | df <- data.frame(c1="123456789123456789",c2=2)
>> | df
>> | #+END_SRC
>> |
>> | #+RESULTS:
>> | : c1 c2
>> | : 1 123456789123456789 2
>> `----
>>
>
> With :results output the results aren't translated into emacs-lisp.
> Instead, the output from the source language is collected and displayed
> in the buffer. Thus, the output conventions of the source language are
> respected.
>
> hth,
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: was this intentional with the default header ":results value"
2012-07-15 1:00 ` Eric Luo
@ 2012-07-15 3:33 ` Thomas S. Dye
2012-07-15 3:54 ` Thomas S. Dye
0 siblings, 1 reply; 6+ messages in thread
From: Thomas S. Dye @ 2012-07-15 3:33 UTC (permalink / raw)
To: Eric Luo; +Cc: emacs-orgmode
Hi Eric,
I don't know any way to do this in Org-mode. Here is a workaround in R
that might do what you want.
#+name: luo
#+BEGIN_SRC R :results output org
library(ascii)
df <- data.frame(c1="123456789123456789000",c2=2)
df$c1 <- as.vector(df$c1)
print(ascii(df),type="org")
#+END_SRC
#+RESULTS: luo
#+BEGIN_ORG
| | c1 | c2 |
|---+-----------------------+------|
| 1 | 123456789123456789000 | 2.00 |
#+END_ORG
All the best,
Tom
Eric Luo <eric.wenbl@gmail.com> writes:
> tsd@tsdye.com (Thomas S. Dye) writes:
>
> Thanks, it's clear to me with the difference between "value" and
> "output" now.
>
> whether there is a way to tell emacs-lisp that "123456789123456789" is a
> string rather than a number.
>
> emacs-lisp handles the output as expected if the c1 has any character
> other than numbers as the following.
> ,----
> | #+BEGIN_SRC R
> | df <- data.frame(c1="c123456789123456789",c2=2)
> | df$c1 <- as.vector(df$c1)
> | df
> | #+END_SRC
> |
> | #+RESULTS:
> | | c123456789123456789 | 2 |
> |
> `----
>
>> Aloha Eric,
>>
>> Eric Luo <eric.wenbl@gmail.com> writes:
>>
>>> Hi,
>>> Why in the following code block, c1 was printed as scientific notation
>>> rather then characters.
>>> ,----
>>> |
>>> | #+BEGIN_SRC R :results value
>>> | df <- data.frame(c1="123456789123456789",c2=2)
>>> | #+END_SRC
>>> |
>>> | #+RESULTS:
>>> | | 1.2345678912345678e+17 | 2 |
>>> `----
>>
>> With :results value the results are passed from the source language into
>> emacs-lisp and then displayed in the buffer. So, the representation of
>> things like very large numbers depends on how that was done in
>> emacs-lisp, independent of the source language conventions. In this
>> case, I suspect the number was written with a formatting string and ‘%g’
>> which uses scientific notation if that is a shorter representation.
>>
>>
>>> But if the header :results output, the result was expected.
>>> ,----
>>> |
>>> | #+BEGIN_SRC R :results output
>>> | df <- data.frame(c1="123456789123456789",c2=2)
>>> | df
>>> | #+END_SRC
>>> |
>>> | #+RESULTS:
>>> | : c1 c2
>>> | : 1 123456789123456789 2
>>> `----
>>>
>>
>> With :results output the results aren't translated into emacs-lisp.
>> Instead, the output from the source language is collected and displayed
>> in the buffer. Thus, the output conventions of the source language are
>> respected.
>>
>> hth,
>
>
>
--
Thomas S. Dye
http://www.tsdye.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: was this intentional with the default header ":results value"
2012-07-15 3:33 ` Thomas S. Dye
@ 2012-07-15 3:54 ` Thomas S. Dye
2012-07-15 9:18 ` Eric Luo
0 siblings, 1 reply; 6+ messages in thread
From: Thomas S. Dye @ 2012-07-15 3:54 UTC (permalink / raw)
To: Eric Luo; +Cc: emacs-orgmode
Or, fiddling a bit more.
#+name: luo
#+BEGIN_SRC R :results output raw
library(ascii)
df <- data.frame(c1="123456789123456789000",c2=2)
df$c1 <- as.vector(df$c1)
print(ascii(df,digits=c(0,0),include.rownames=F),type="org")
#+END_SRC
#+RESULTS: luo
| c1 | c2 |
|-----------------------+----|
| 123456789123456789000 | 2 |
tsd@tsdye.com (Thomas S. Dye) writes:
> Hi Eric,
>
> I don't know any way to do this in Org-mode. Here is a workaround in R
> that might do what you want.
>
> #+name: luo
> #+BEGIN_SRC R :results output org
> library(ascii)
> df <- data.frame(c1="123456789123456789000",c2=2)
> df$c1 <- as.vector(df$c1)
> print(ascii(df),type="org")
> #+END_SRC
>
> #+RESULTS: luo
> #+BEGIN_ORG
> | | c1 | c2 |
> |---+-----------------------+------|
> | 1 | 123456789123456789000 | 2.00 |
> #+END_ORG
>
> All the best,
> Tom
>
> Eric Luo <eric.wenbl@gmail.com> writes:
>
>> tsd@tsdye.com (Thomas S. Dye) writes:
>>
>> Thanks, it's clear to me with the difference between "value" and
>> "output" now.
>>
>> whether there is a way to tell emacs-lisp that "123456789123456789" is a
>> string rather than a number.
>>
>> emacs-lisp handles the output as expected if the c1 has any character
>> other than numbers as the following.
>> ,----
>> | #+BEGIN_SRC R
>> | df <- data.frame(c1="c123456789123456789",c2=2)
>> | df$c1 <- as.vector(df$c1)
>> | df
>> | #+END_SRC
>> |
>> | #+RESULTS:
>> | | c123456789123456789 | 2 |
>> |
>> `----
>>
>>> Aloha Eric,
>>>
>>> Eric Luo <eric.wenbl@gmail.com> writes:
>>>
>>>> Hi,
>>>> Why in the following code block, c1 was printed as scientific notation
>>>> rather then characters.
>>>> ,----
>>>> |
>>>> | #+BEGIN_SRC R :results value
>>>> | df <- data.frame(c1="123456789123456789",c2=2)
>>>> | #+END_SRC
>>>> |
>>>> | #+RESULTS:
>>>> | | 1.2345678912345678e+17 | 2 |
>>>> `----
>>>
>>> With :results value the results are passed from the source language into
>>> emacs-lisp and then displayed in the buffer. So, the representation of
>>> things like very large numbers depends on how that was done in
>>> emacs-lisp, independent of the source language conventions. In this
>>> case, I suspect the number was written with a formatting string and ‘%g’
>>> which uses scientific notation if that is a shorter representation.
>>>
>>>
>>>> But if the header :results output, the result was expected.
>>>> ,----
>>>> |
>>>> | #+BEGIN_SRC R :results output
>>>> | df <- data.frame(c1="123456789123456789",c2=2)
>>>> | df
>>>> | #+END_SRC
>>>> |
>>>> | #+RESULTS:
>>>> | : c1 c2
>>>> | : 1 123456789123456789 2
>>>> `----
>>>>
>>>
>>> With :results output the results aren't translated into emacs-lisp.
>>> Instead, the output from the source language is collected and displayed
>>> in the buffer. Thus, the output conventions of the source language are
>>> respected.
>>>
>>> hth,
>>
>>
>>
--
Thomas S. Dye
http://www.tsdye.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: was this intentional with the default header ":results value"
2012-07-15 3:54 ` Thomas S. Dye
@ 2012-07-15 9:18 ` Eric Luo
0 siblings, 0 replies; 6+ messages in thread
From: Eric Luo @ 2012-07-15 9:18 UTC (permalink / raw)
To: emacs-orgmode
tsd@tsdye.com (Thomas S. Dye) writes:
> Or, fiddling a bit more.
>
> #+name: luo
> #+BEGIN_SRC R :results output raw
> library(ascii)
> df <- data.frame(c1="123456789123456789000",c2=2)
> df$c1 <- as.vector(df$c1)
> print(ascii(df,digits=c(0,0),include.rownames=F),type="org")
> #+END_SRC
>
> #+RESULTS: luo
> | c1 | c2 |
> |-----------------------+----|
> | 123456789123456789000 | 2 |
>
Thanks for your help in time, it works like in a charm.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-07-15 9:19 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-13 14:24 was this intentional with the default header ":results value" Eric Luo
2012-07-14 16:44 ` Thomas S. Dye
2012-07-15 1:00 ` Eric Luo
2012-07-15 3:33 ` Thomas S. Dye
2012-07-15 3:54 ` Thomas S. Dye
2012-07-15 9:18 ` Eric Luo
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.