emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Formatting R output
@ 2012-09-10 12:12 Neuwirth Erich
  0 siblings, 0 replies; 4+ messages in thread
From: Neuwirth Erich @ 2012-09-10 12:12 UTC (permalink / raw)
  To: emacs-orgmode@gnu.org emacs-orgmode@gnu.org

I am using org-mode with R.
I already wrote a message about formatting inline code some time ago.
After working more with R in org-mode (which I _really_ like) I have some
questions and/or suggestions.

1) a mild annoyance.

src_R{1+1} inserts the result 2 in the output. In fact, it inserts =2=.
When one runs the file repeatedly, org-mode does not remove older results.
So if I replace src_R{1+1} by src_R{2+2} and do not remove the last output,
My file will contain 

src_R{2+2} =4= =2= 

Also, If I run the inline code segment by C-c C-c one, the org file ail contain just 1
correct result, bit if afterwards I export the file (to LaTeX or html),
the exported file will have 2 copies of the result.

Is there anything the developers can do about this?

2) formatting inline output.
As discussed above, using inline code produces something like
src_R{2+2} =4=

In some cases, I would like the result to be not on fixed font.
Currently, I to not see a way of removing the equal signs before and after the result,
they seem to be added by org itself, therefore I cannot use trickery in R to remove them.
Could the developers think of an option which would allow to get the result
without the bracketing equal signs?

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

* Re: Formatting R output
@ 2012-09-10 14:48 G. Jay Kerns
  2012-09-10 15:06 ` Nick Dokos
  0 siblings, 1 reply; 4+ messages in thread
From: G. Jay Kerns @ 2012-09-10 14:48 UTC (permalink / raw)
  To: emacs-orgmode

Dear Erich,

comments inline below.

> From: Neuwirth Erich <erich.neuwirth <at> univie.ac.at>
> Subject: Formatting R output
> Newsgroups: gmane.emacs.orgmode
> Date: 2012-09-10 12:12:00 GMT
>
> I am using org-mode with R.
> I already wrote a message about formatting inline code some time ago.
> After working more with R in org-mode (which I _really_ like) I have some
> questions and/or suggestions.
>
> 1) a mild annoyance.
>
> src_R{1+1} inserts the result 2 in the output. In fact, it inserts =2=.
> When one runs the file repeatedly, org-mode does not remove older results.
> So if I replace src_R{1+1} by src_R{2+2} and do not remove the last output,
> My file will contain
>
> src_R{2+2} =4= =2=
>
> Also, If I run the inline code segment by C-c C-c one, the org file ail contain just 1
> correct result, bit if afterwards I export the file (to LaTeX or html),
> the exported file will have 2 copies of the result.
>
> Is there anything the developers can do about this?

I can confirm that if a person does not remove old output but changes
input to the inline code segment then the exported file will have both
the correct output plus the (old) incorrect output.  My strategy to
avoid this is use C-c C-c sparingly just to check whether the output
is as expected, then always erase output.  If I am going to use an org
file with C-c C-c a lot (for a lecture, say), then I keep a copy for
exporting clean and separate from the one I am going to do a lot of
C-c C-c'ing with.  YMMV.


> 2) formatting inline output.
> As discussed above, using inline code produces something like
> src_R{2+2} =4=
>
> In some cases, I would like the result to be not on fixed font.
> Currently, I to not see a way of removing the equal signs before and after the result,
> they seem to be added by org itself, therefore I cannot use trickery in R to remove them.
> Could the developers think of an option which would allow to get the result
> without the bracketing equal signs?

I think you can fix this with inline code-segment header arguments
which will override buffer-wide or system wide settings.  So, for
example, you could do

src_R[:results raw]{2 + 2}

which will return 4 and not =4=.

I hope this helps,
Jay


-- 


*************************************
G. Jay Kerns, Ph.D.
Associate Professor
Mathematics and Statistics
http://people.ysu.edu/~gkerns/

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

* Re: Formatting R output
  2012-09-10 14:48 G. Jay Kerns
@ 2012-09-10 15:06 ` Nick Dokos
  2012-09-10 15:17   ` Nick Dokos
  0 siblings, 1 reply; 4+ messages in thread
From: Nick Dokos @ 2012-09-10 15:06 UTC (permalink / raw)
  To: G. Jay Kerns; +Cc: emacs-orgmode

G. Jay Kerns <gkerns@ysu.edu> wrote:

> > From: Neuwirth Erich <erich.neuwirth <at> univie.ac.at>
> > ...
> > 1) a mild annoyance.
> >
> > src_R{1+1} inserts the result 2 in the output. In fact, it inserts =2=.
> > When one runs the file repeatedly, org-mode does not remove older results.
> > So if I replace src_R{1+1} by src_R{2+2} and do not remove the last output,
> > My file will contain
> >
> > src_R{2+2} =4= =2=
> >
> > Also, If I run the inline code segment by C-c C-c one, the org file ail contain just 1
> > correct result, bit if afterwards I export the file (to LaTeX or html),
> > the exported file will have 2 copies of the result.
> >
> > Is there anything the developers can do about this?
> 
> I can confirm that if a person does not remove old output but changes
> input to the inline code segment then the exported file will have both
> the correct output plus the (old) incorrect output.  My strategy to
> avoid this is use C-c C-c sparingly just to check whether the output
> is as expected, then always erase output.  If I am going to use an org
> file with C-c C-c a lot (for a lecture, say), then I keep a copy for
> exporting clean and separate from the one I am going to do a lot of
> C-c C-c'ing with.  YMMV.
> 

IMO, the solution would come in two pieces:

- an org-babel-before-execute-hook to complement the org-babel-after-execute-hook
- fixing org-remove-result to work with inline source code blocks - my
  attempt to use it zapped the closing brace as well as the actual
  result: "This is R code: src_R{2 + 2".

Given these two however, you could add the remove function to the hook and
that'd be that.

Nick



  

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

* Re: Formatting R output
  2012-09-10 15:06 ` Nick Dokos
@ 2012-09-10 15:17   ` Nick Dokos
  0 siblings, 0 replies; 4+ messages in thread
From: Nick Dokos @ 2012-09-10 15:17 UTC (permalink / raw)
  Cc: emacs-orgmode, G. Jay Kerns

Nick Dokos <nicholas.dokos@hp.com> wrote:

> G. Jay Kerns <gkerns@ysu.edu> wrote:
> 
> > > From: Neuwirth Erich <erich.neuwirth <at> univie.ac.at>
> > > ...
> > > 1) a mild annoyance.
> > >
> > > src_R{1+1} inserts the result 2 in the output. In fact, it inserts =2=.
> > > When one runs the file repeatedly, org-mode does not remove older results.
> > > So if I replace src_R{1+1} by src_R{2+2} and do not remove the last output,
> > > My file will contain
> > >
> > > src_R{2+2} =4= =2=
> > >
> > > Also, If I run the inline code segment by C-c C-c one, the org file ail contain just 1
> > > correct result, bit if afterwards I export the file (to LaTeX or html),
> > > the exported file will have 2 copies of the result.
> > >
> > > Is there anything the developers can do about this?
> > 
> > I can confirm that if a person does not remove old output but changes
> > input to the inline code segment then the exported file will have both
> > the correct output plus the (old) incorrect output.  My strategy to
> > avoid this is use C-c C-c sparingly just to check whether the output
> > is as expected, then always erase output.  If I am going to use an org
> > file with C-c C-c a lot (for a lecture, say), then I keep a copy for
> > exporting clean and separate from the one I am going to do a lot of
> > C-c C-c'ing with.  YMMV.
> > 
> 
> IMO, the solution would come in two pieces:
> 
> - an org-babel-before-execute-hook to complement the org-babel-after-execute-hook
> - fixing org-remove-result to work with inline source code blocks - my
>   attempt to use it zapped the closing brace as well as the actual
>   result: "This is R code: src_R{2 + 2".
> 

Scratch that: org-babel-remove-result would need delimiters to know what to remove.

It currently removes everything to the end of the line which seems not
quite kosher, but I'm not sure what the correct thing to do would be.

Nick

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

end of thread, other threads:[~2012-09-10 15:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-10 12:12 Formatting R output Neuwirth Erich
  -- strict thread matches above, loose matches on Subject: below --
2012-09-10 14:48 G. Jay Kerns
2012-09-10 15:06 ` Nick Dokos
2012-09-10 15:17   ` Nick Dokos

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).