Stephen Eglen | 2 Jun 2012 11:01
Picon
Picon
Favicon

knitr


With useR 2012 coming soon, can someone report back on what the
community feels about packages like knitr, as an alternative to sweave?
I see that Rstudio recently built in support for knitr, should we try
the same for ESS?  Or is it too early to tell?

  http://www.r-bloggers.com/new-version-of-rstudio-v0-96/

Stephen

______________________________________________
ESS-help <at> r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help

Vitalie Spinu | 2 Jun 2012 11:56
Picon
Gravatar

Re: knitr


Would be great. I think it's time to rewrite our noweb support to make
it more generic and backend independent.

KnitR allows for custom regexp for chunk delimiter. This would allow
proper indentation of TeX and R code.

Vitalie.

  >> Stephen Eglen <S.J.Eglen <at> damtp.cam.ac.uk>
  >> on Sat, 02 Jun 2012 10:01:01 +0100 wrote:

  > With useR 2012 coming soon, can someone report back on what the
  > community feels about packages like knitr, as an alternative to sweave?
  > I see that Rstudio recently built in support for knitr, should we try
  > the same for ESS?  Or is it too early to tell?

  >   http://www.r-bloggers.com/new-version-of-rstudio-v0-96/

  > Stephen

  > ______________________________________________
  > ESS-help <at> r-project.org mailing list
  > https://stat.ethz.ch/mailman/listinfo/ess-help

______________________________________________
ESS-help <at> r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help

(Continue reading)

Kasper Daniel Hansen | 2 Jun 2012 16:21
Picon

Re: knitr

I have not used knitr myself, but judging from the noise on the
internet it seems to have taken off.  Of course, we still need to have
good support for Sweave, since that is likely to stay around as a
major tool for documentation in R packages.

Kasper

On Sat, Jun 2, 2012 at 5:56 AM, Vitalie Spinu <spinuvit <at> gmail.com> wrote:
>
> Would be great. I think it's time to rewrite our noweb support to make
> it more generic and backend independent.
>
> KnitR allows for custom regexp for chunk delimiter. This would allow
> proper indentation of TeX and R code.
>
> Vitalie.
>
>  >> Stephen Eglen <S.J.Eglen <at> damtp.cam.ac.uk>
>  >> on Sat, 02 Jun 2012 10:01:01 +0100 wrote:
>
>  > With useR 2012 coming soon, can someone report back on what the
>  > community feels about packages like knitr, as an alternative to sweave?
>  > I see that Rstudio recently built in support for knitr, should we try
>  > the same for ESS?  Or is it too early to tell?
>
>  >   http://www.r-bloggers.com/new-version-of-rstudio-v0-96/
>
>  > Stephen
>
>  > ______________________________________________
(Continue reading)

Stephen Eglen | 2 Jun 2012 17:37
Picon
Picon
Favicon

Re: knitr


> Would be great. I think it's time to rewrite our noweb support to make
> it more generic and backend independent.
agree!

> KnitR allows for custom regexp for chunk delimiter. This would allow
> proper indentation of TeX and R code.
I don't quite follow - what would be the best chunk delimeter in this
case -- would the <<>> and  <at>  (noweb) not suffice?  Might Emacs support for
custom regexps make the multiple-mode support tricky?

Stephen

______________________________________________
ESS-help <at> r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help

Vitalie Spinu | 2 Jun 2012 17:55
Picon
Gravatar

Re: knitr

  >> Stephen Eglen <S.J.Eglen <at> damtp.cam.ac.uk>
  >> on Sat, 02 Jun 2012 16:37:34 +0100 wrote:

  >> KnitR allows for custom regexp for chunk delimiter. This would allow
  >> proper indentation of TeX and R code.
  > I don't quite follow - what would be the best chunk delimeter in this
  > case -- would the <<>> and  <at>  (noweb) not suffice?  

It's not just <<>> and  <at>  it's ^<<>> and ^ <at> . This ruins LaTeX indentation
when R chunks are not at the top level. Would be good not to pin them to
the bol.

  > Might Emacs support for custom regexps make the multiple-mode
  > support tricky?

Might be tricky. But this should be a user problem who plans to change
the delimiter. If we can make noweb generically depend on customizable
delimiter and ensure that it works with standard delimiters, our job is
done.

Vitalie.

______________________________________________
ESS-help <at> r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help

Yihui Xie | 2 Jun 2012 16:48
Favicon
Gravatar

Re: knitr

I asked knitr users about the ESS support and here is one contribution
from them: http://sjp.co.nz/posts/emacs-ess-knitr/ It seems to be in
rough edges, but should be a good proof of concept.

I will be glad if knitr is going to the official ESS. As Vitalie
mentioned, the noweb support can be backend independent, so that users
can define how to weave the Rnw file.

Or you can take an even further step to support other file formats
like R HTML, R Markdown, R reStructuredText, ... (knitr supports all
of them) It will be cool to be able to knit() and preview an HTML file
with ESS. From our experience, LaTeX really stopped many people from
playing with literate programming with R.

Thanks!

Regards,
Yihui
--
Yihui Xie <xieyihui <at> gmail.com>
Phone: 515-294-2465 Web: http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA

On Sat, Jun 2, 2012 at 5:01 AM, Stephen Eglen <S.J.Eglen <at> damtp.cam.ac.uk> wrote:
>
> With useR 2012 coming soon, can someone report back on what the
> community feels about packages like knitr, as an alternative to sweave?
> I see that Rstudio recently built in support for knitr, should we try
> the same for ESS?  Or is it too early to tell?
(Continue reading)

Stephen Eglen | 2 Jun 2012 21:17
Picon
Picon
Favicon

Re: knitr

> I asked knitr users about the ESS support and here is one contribution
> from them: http://sjp.co.nz/posts/emacs-ess-knitr/ It seems to be in
> rough edges, but should be a good proof of concept.
Great, thanks.

> Or you can take an even further step to support other file formats
> like R HTML, R Markdown, R reStructuredText, ... (knitr supports all
> of them) It will be cool to be able to knit() and preview an HTML file
> with ESS. From our experience, LaTeX really stopped many people from
> playing with literate programming with R.

That's interesting that LaTeX was a barrier for R users.  

I've not used Markdown before; it seems neat, but what does it offer
that org mode doesn't?  I see there is a markdown-mode.el 

http://jblevins.org/projects/markdown-mode/

that has some support for org mode style cycling of outlines.  

Anyone prefer markdown to org mode, and if so why?

(If anyone is interested, on the org mode list recently there was
discussion about exporting org docs to markdown.)

Stephen

______________________________________________
ESS-help <at> r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help
(Continue reading)

Yihui Xie | 3 Jun 2012 00:08
Favicon
Gravatar

Re: knitr

There is no point comparing markdown with org mode, and the answer
will be definitely this: org mode can beat markdown almost everywhere;
they are not even comparable. The point is that markdown was not
designed to provide new features; it was designed to be simple so it
intentionally discarded lots of features and people can learn it
quickly. I have tried a few times to learn org mode, and it is just
too complicated for me.

Regards,
Yihui
--
Yihui Xie <xieyihui <at> gmail.com>
Phone: 515-294-2465 Web: http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA

On Sat, Jun 2, 2012 at 3:17 PM, Stephen Eglen <S.J.Eglen <at> damtp.cam.ac.uk> wrote:
>
> That's interesting that LaTeX was a barrier for R users.
>
> I've not used Markdown before; it seems neat, but what does it offer
> that org mode doesn't?  I see there is a markdown-mode.el
>
> http://jblevins.org/projects/markdown-mode/
>
> that has some support for org mode style cycling of outlines.
>
> Anyone prefer markdown to org mode, and if so why?
>
> (If anyone is interested, on the org mode list recently there was
(Continue reading)

Michael Hannon | 3 Jun 2012 00:21
Picon
Favicon
Gravatar

Difficulty of using Org mode

Hi, folks.  Just FYI:

----- Forwarded Message -----
>From: Yihui Xie <xie <at> yihui.name>
>To: Stephen Eglen <S.J.Eglen <at> damtp.cam.ac.uk> 
>Cc: ESS-help <at> r-project.org 
>Sent: Saturday, June 2, 2012 3:08 PM
>Subject: Re: [ESS] knitr
> 
>There is no point comparing markdown with org mode, and the answer
>will be definitely this: org mode can beat markdown almost everywhere;
>they are not even comparable. The point is that markdown was not
>designed to provide new features; it was designed to be simple so it
>intentionally discarded lots of features and people can learn it
>quickly. I have tried a few times to learn org mode, and it is just
>too complicated for me.
>
>Regards,
>Yihui
>--
>Yihui Xie <xieyihui <at> gmail.com>
>Phone: 515-294-2465 Web: http://yihui.name
>Department of Statistics, Iowa State University
>2215 Snedecor Hall, Ames, IA
>
>
>On Sat, Jun 2, 2012 at 3:17 PM, Stephen Eglen <S.J.Eglen <at> damtp.cam.ac.uk> wrote:
>>
>> That's interesting that LaTeX was a barrier for R users.
>>
(Continue reading)

Bastien | 4 Jun 2012 08:29
Picon
Gravatar

Re: Difficulty of using Org mode

Hi Michael,

Michael Hannon <jm_hannon <at> yahoo.com> writes:

> Hi, folks.  Just FYI:
>
> ----- Forwarded Message -----
>>From: Yihui Xie <xie <at> yihui.name>
>>To: Stephen Eglen <S.J.Eglen <at> damtp.cam.ac.uk> 
>>Cc: ESS-help <at> r-project.org 
>>Sent: Saturday, June 2, 2012 3:08 PM
>>Subject: Re: [ESS] knitr
>> 
>>There is no point comparing markdown with org mode, and the answer
>>will be definitely this: org mode can beat markdown almost everywhere;
>>they are not even comparable. The point is that markdown was not
>>designed to provide new features; it was designed to be simple so it
>>intentionally discarded lots of features and people can learn it
>>quickly. I have tried a few times to learn org mode, and it is just
>>too complicated for me.

Well, it all boils down to disambiguate what "learning Org" means.

It is hard to say just from the message above.  If you can, please
redirect the OP to this list so that he feels guided in tasks he wants
to do with Org.

--

-- 
 Bastien

(Continue reading)

Michael Hannon | 4 Jun 2012 09:46
Picon
Favicon
Gravatar

Re: Difficulty of using Org mode

Bastien <bzg <at> gnu.org> wrote:

>Michael Hannon <jm_hannon <at> yahoo.com> writes:
>
>> Hi, folks.  Just FYI:
>>
>> ----- Forwarded Message -----
>>>From: Yihui Xie <xie <at> yihui.name>
>>>To: Stephen Eglen <S.J.Eglen <at> damtp.cam.ac.uk>
>>>Cc: ESS-help <at> r-project.org
>>>Sent: Saturday, June 2, 2012 3:08 PM
>>>Subject: Re: [ESS] knitr
>>>
>>>There is no point comparing markdown with org mode, and the answer
>>>will be definitely this: org mode can beat markdown almost everywhere;
>>>they are not even comparable. The point is that markdown was not
>>>designed to provide new features; it was designed to be simple so it
>>>intentionally discarded lots of features and people can learn it
>>>quickly. I have tried a few times to learn org mode, and it is just
>>>too complicated for me.
>
> Well, it all boils down to disambiguate what "learning Org" means.
>

> It is hard to say just from the message above.  If you can, please redirect
> the OP to this list so that he feels guided in tasks he wants to do with
> Org.

Hi, Bastien.  I don't know this guy, but I don't think he's *trying* to learn
Org mode at this point.  He seems to be a very capable guy:
(Continue reading)

Stephen Eglen | 5 Jun 2012 17:09
Picon
Picon
Favicon

Re: Difficulty of using Org mode


As Yihui was following up to an email of mine about Org mode on the ESS
(emacs speaks statistics list), I will email him to find out if I can
see what issues he had.  For the record: I also found learning Org mode
quite challenging, and I consider myself a diehard Emacs person.  I
guess if you were to ask me what I found difficult, was that it was
quite overwhelming knowing where to start.  (So I started small by
learning the agenda features...)

Stephen

Michael Hannon <jm_hannon <at> yahoo.com> writes:

> Bastien <bzg <at> gnu.org> wrote:
>
>>Michael Hannon <jm_hannon <at> yahoo.com> writes:
>>
>>> Hi, folks.  Just FYI:
>>>
>>> ----- Forwarded Message -----
>>>>From: Yihui Xie <xie <at> yihui.name>
>>>>To: Stephen Eglen <S.J.Eglen <at> damtp.cam.ac.uk>
>>>>Cc: ESS-help <at> r-project.org
>>>>Sent: Saturday, June 2, 2012 3:08 PM
>>>>Subject: Re: [ESS] knitr
>>>>
>>>>There is no point comparing markdown with org mode, and the answer
>>>>will be definitely this: org mode can beat markdown almost everywhere;
>>>>they are not even comparable. The point is that markdown was not
>>>>designed to provide new features; it was designed to be simple so it
(Continue reading)

suvayu ali | 5 Jun 2012 19:25
Picon
Gravatar

Re: Difficulty of using Org mode

Hi,

On Tue, Jun 5, 2012 at 5:09 PM, Stephen Eglen <S.J.Eglen <at> damtp.cam.ac.uk> wrote:
> I guess if you were to ask me what I found difficult, was that it was
> quite overwhelming knowing where to start.  (So I started small by
> learning the agenda features...)

IMO the reason many have this problem because they think "I need to know
everything Org-mode can do" or "I want to customise Org-mode" from the
very beginning.

The way I went about it was to get an overview of the capabilities from
Worg and start using only the features I needed (in my case note taking
and export). As I became more familiar, I delved into other features
(like agenda, babel) and customisation of the already familiar features
(e.g. custom export hooks, personalised colour theme etc).

Idea: Maybe this could be a nice entry on the FAQ, "Where do I start?".
Maybe even a dedicated page on the Worg Index page. Any volunteers?

:)

--

-- 
Suvayu

Open source is the future. It sets us free.

Memnon Anon | 6 Jun 2012 18:48

Re: Difficulty of using Org mode

suvayu ali <fatkasuvayu+linux <at> gmail.com> writes:

> The way I went about it was to get an overview of the capabilities from
> Worg and start using only the features I needed (in my case note taking
> and export). As I became more familiar, I delved into other features
> (like agenda, babel) and customisation of the already familiar features
> (e.g. custom export hooks, personalised colour theme etc).

And this is exactly what orgmode.org tells you from the start:

,----[ http://www.orgmode.org ]
| Simplicity
|     At its core, Org mode is a simple outliner for note-taking and list
|     management. You can learn the basics for using it in five minutes.
|     This may be all you need, and Org mode will not impose more complex
|     features on you. 
`----

with a link to
     http://orgmode.org/worg/org-tutorials/orgtutorial_dto.html

There is also the compact guide, which is the first link on the
documentation page:
     http://orgmode.org/guide/index.html

I don't know how hard org is (or is not) for emacs users; I came to
emacs because of org and started from there :). My first post to this
list is from mid 2008 (... that long already?) and it is getting more
and more complex; I could pick up new features along the way.

(Continue reading)

Stephen Eglen | 5 Jun 2012 23:59
Picon
Picon
Favicon

Re: knitr

> There is no point comparing markdown with org mode, and the answer
> will be definitely this: org mode can beat markdown almost everywhere;
> they are not even comparable. The point is that markdown was not
> designed to provide new features; it was designed to be simple so it
> intentionally discarded lots of features and people can learn it
> quickly. I have tried a few times to learn org mode, and it is just
> too complicated for me.
>
Thanks; this confirms what I thought, that markdown is streamlined.  

I did also find org mode quite complicated, as when I started using it,
it was already quite a fully-featured machine.  I started by learning
some small aspects first, and then gradually expanding.  I don't know if
it helps you, but I wrote some org-babel material last year for the ESS
tutorial at useR last year:

http://www.damtp.cam.ac.uk/user/sje30/ess11/index.html

If it looks like there is interest in combining org with knitR, then
this might be a good place to discuss it (or the org-mode list, as there
are quite a few users there who use R).

My approach to learning org mode was to start simple, with one feature
at a time.  Did you recall if there was anything in particular that you
had difficulty getting started with?

Thanks, Stephen

______________________________________________
ESS-help <at> r-project.org mailing list
(Continue reading)

Yihui Xie | 6 Jun 2012 17:22
Favicon
Gravatar

Re: knitr

Well, obviously I do not have a strong desire to try to learn org-mode
again; I just tried to look at the documentation one more time, and I
think I get the idea more or less. Org-babel is another monster, and I
do not have time to spend on it at the moment.

One thing that I worked hard on knitr is that you do not have to set
any chunk options, and you will still get everything just as if you
pasted the code in R. No need for :file or :results. If your R code
produces plots, all of them will be captured and written in the
output. With editor support like RStudio/LyX/Eclipse/..., all you need
to do is write text mixed with code, and hit the button. This is
hopefully easier for beginners to start with. I'm not sure how high is
the barrier of Emacs + Org-mode + LaTeX.

Sorry that sounds to be off-topic. For the integration of org-mode and
knitr, I guess there is at least one difficulty because they have
different philosophies in terms of code block options -- knitr treats
these options as R code, e.g. you can set fig.width=5+2-1 and knitr
will evaluate the option to get 6; Sweave and org-mode treats them as
normal character strings. Finally one knitr user ended up with this
"cheating" solution: http://yihui.name/knitr/demo/org/

So I'd love to see the knitr support in ESS just like the support to
Sweave and leave org-mode alone at the moment. Thanks!

Regards,
Yihui
--
Yihui Xie <xieyihui <at> gmail.com>
Phone: 515-294-2465 Web: http://yihui.name
(Continue reading)

Vitalie Spinu | 2 Oct 2012 20:20
Picon
Gravatar

Re: knitr

  >> Yihui Xie <xie <at> yihui.name>
  >> on Sat, 2 Jun 2012 10:48:40 -0400 wrote:

  > I asked knitr users about the ESS support and here is one contribution
  > from them: http://sjp.co.nz/posts/emacs-ess-knitr/ It seems to be in
  > rough edges, but should be a good proof of concept.

  > I will be glad if knitr is going to the official ESS. As Vitalie
  > mentioned, the noweb support can be backend independent, so that
  > users can define how to weave the Rnw file.

I have just added knitr processor for Rnw files to the trunk. That is,
there is a customizable ess-swv-processor variable, which, if set to
'knitr, makes "M-n s" to knit instead of Sweave, and "M-n T" to purl
instead of Stangle.

There are also specialized ess-swv-knit and ess-swv-purl bound to "M-n
r" and "M-n u" exactly as in the above add-on by Simon Potter.

Will be available in a patch release pretty soon. 

  > Or you can take an even further step to support other file formats
  > like R HTML, R Markdown, R reStructuredText, ... (knitr supports all
  > of them) It will be cool to be able to knit() and preview an HTML file
  > with ESS. From our experience, LaTeX really stopped many people from
  > playing with literate programming with R.

This functionality is unfortunately delayed, but will be available in
the next version of ESS.

(Continue reading)

Yihui Xie | 2 Oct 2012 21:50
Favicon
Gravatar

Re: knitr

Just tested with the SVN source and it works perfect. Thanks!

Regards,
Yihui
--
Yihui Xie <xieyihui <at> gmail.com>
Phone: 515-294-2465 Web: http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA

On Tue, Oct 2, 2012 at 1:20 PM, Vitalie Spinu <spinuvit <at> gmail.com> wrote:
>   >> Yihui Xie <xie <at> yihui.name>
>   >> on Sat, 2 Jun 2012 10:48:40 -0400 wrote:
>
>   > I asked knitr users about the ESS support and here is one contribution
>   > from them: http://sjp.co.nz/posts/emacs-ess-knitr/ It seems to be in
>   > rough edges, but should be a good proof of concept.
>
>   > I will be glad if knitr is going to the official ESS. As Vitalie
>   > mentioned, the noweb support can be backend independent, so that
>   > users can define how to weave the Rnw file.
>
> I have just added knitr processor for Rnw files to the trunk. That is,
> there is a customizable ess-swv-processor variable, which, if set to
> 'knitr, makes "M-n s" to knit instead of Sweave, and "M-n T" to purl
> instead of Stangle.
>
> There are also specialized ess-swv-knit and ess-swv-purl bound to "M-n
> r" and "M-n u" exactly as in the above add-on by Simon Potter.
>
(Continue reading)

Tengfei Yin | 2 Oct 2012 21:59
Picon
Gravatar

Re: knitr

Awesome, thanks a lot  for you guys' hard work!

On Tue, Oct 2, 2012 at 2:50 PM, Yihui Xie <xie <at> yihui.name> wrote:

> Just tested with the SVN source and it works perfect. Thanks!
>
> Regards,
> Yihui
> --
> Yihui Xie <xieyihui <at> gmail.com>
> Phone: 515-294-2465 Web: http://yihui.name
> Department of Statistics, Iowa State University
> 2215 Snedecor Hall, Ames, IA
>
>
> On Tue, Oct 2, 2012 at 1:20 PM, Vitalie Spinu <spinuvit <at> gmail.com> wrote:
> >   >> Yihui Xie <xie <at> yihui.name>
> >   >> on Sat, 2 Jun 2012 10:48:40 -0400 wrote:
> >
> >   > I asked knitr users about the ESS support and here is one
> contribution
> >   > from them: http://sjp.co.nz/posts/emacs-ess-knitr/ It seems to be in
> >   > rough edges, but should be a good proof of concept.
> >
> >   > I will be glad if knitr is going to the official ESS. As Vitalie
> >   > mentioned, the noweb support can be backend independent, so that
> >   > users can define how to weave the Rnw file.
> >
> > I have just added knitr processor for Rnw files to the trunk. That is,
> > there is a customizable ess-swv-processor variable, which, if set to
(Continue reading)

Pierre Kleiber | 2 Oct 2012 22:38
Picon

Re: knitr

Being a long-time user of R and ESS but never having tried sweave or other 
literate programing systems, I would like to try knitr. I'm searching for a 
knitr tutorial that makes use of ESS rather than RStudio. Can anyone direct me 
to such a tutorial?

Many thanks, Pierre

Tengfei Yin offered the following remark on 10/02/12 09:59...
> Awesome, thanks a lot  for you guys' hard work!
>
> On Tue, Oct 2, 2012 at 2:50 PM, Yihui Xie<xie <at> yihui.name>  wrote:
>
>> Just tested with the SVN source and it works perfect. Thanks!
>>
>> Regards,
>> Yihui
>> --
>> Yihui Xie<xieyihui <at> gmail.com>
>> Phone: 515-294-2465 Web: http://yihui.name
>> Department of Statistics, Iowa State University
>> 2215 Snedecor Hall, Ames, IA
>>
>>
>> On Tue, Oct 2, 2012 at 1:20 PM, Vitalie Spinu<spinuvit <at> gmail.com>  wrote:
>>>    >>  Yihui Xie<xie <at> yihui.name>
>>>    >>  on Sat, 2 Jun 2012 10:48:40 -0400 wrote:
>>>
>>>    >  I asked knitr users about the ESS support and here is one
>> contribution
>>>    >  from them: http://sjp.co.nz/posts/emacs-ess-knitr/ It seems to be in
(Continue reading)

Yihui Xie | 2 Oct 2012 23:56
Favicon
Gravatar

Re: knitr

Just made a fresh video here and I hope it helps: http://www.screenr.com/Haa8

I found a problem and I'm not sure if it is just me or happens to
other people as well: when I press M-n P, evince does not start up
automatically although I see "xdg-open foo.pdf" from the log; my pdf
files are associated with evince under Ubuntu, and xdg-open foo.pdf in
the terminal works fine.

Regards,
Yihui
--
Yihui Xie <xieyihui <at> gmail.com>
Phone: 515-294-2465 Web: http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA

On Tue, Oct 2, 2012 at 3:38 PM, Pierre Kleiber <pkleiber.hi <at> gmail.com> wrote:
> Being a long-time user of R and ESS but never having tried sweave or other
> literate programing systems, I would like to try knitr. I'm searching for a
> knitr tutorial that makes use of ESS rather than RStudio. Can anyone direct
> me to such a tutorial?
>
> Many thanks, Pierre
>

______________________________________________
ESS-help <at> r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help

(Continue reading)

Vitalie Spinu | 3 Oct 2012 11:21
Picon
Gravatar

Re: knitr

  >> Yihui Xie <xie <at> yihui.name>
  >> on Tue, 2 Oct 2012 16:56:07 -0500 wrote:

  > Just made a fresh video here and I hope it helps: http://www.screenr.com/Haa8
  > I found a problem and I'm not sure if it is just me or happens to
  > other people as well: when I press M-n P, evince does not start up
  > automatically although I see "xdg-open foo.pdf" from the log; my pdf
  > files are associated with evince under Ubuntu, and xdg-open foo.pdf in
  > the terminal works fine.

Works for me in kubuntu, but I remember having issues with it that had
nothing to do emacs/ESS. And I don't remember how I solved that :( Some
window filtering settings I guess.

    Vitalie.

______________________________________________
ESS-help <at> r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help

Stephen Eglen | 2 Oct 2012 22:57
Picon
Picon
Favicon

Re: knitr

> I have just added knitr processor for Rnw files to the trunk. That is,
> there is a customizable ess-swv-processor variable, which, if set to
> 'knitr, makes "M-n s" to knit instead of Sweave, and "M-n T" to purl
> instead of Stangle.
>
> There are also specialized ess-swv-knit and ess-swv-purl bound to "M-n
> r" and "M-n u" exactly as in the above add-on by Simon Potter.

Thanks Vitalie!

Is there a reliable way of discriminating a Sweave file from a knitr
file?  If so, it could be used to set this variable
(ess-swv-processor).  However, I can think of only 

\usepackage{Sweave}  

and that is not foolproof (e.g. \RequirePackage is similar).

I'm in a transition period -- I have several Sweave files, and think
knitr is more flexible, so currently am writing new docs in knitr.

Stephen

______________________________________________
ESS-help <at> r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help

Yihui Xie | 2 Oct 2012 23:05
Favicon
Gravatar

Re: knitr

There is 100% guarantee for *.Rnw documents; one thing I can think of
is to see if opts_chunk is used in the document, e.g.
opts_chunk$set(echo = TRUE). This is unique to knitr. Other minor
differences are like results='hide' (knitr) vs results=hide (Sweave).

If a document uses \usepackage{Sweave}, it is more likely to be Sweave
because knitr does not need this. The other approach is to check if
(require('knitr')) in R before weaving the file.

*.Rmd/*.Rhtml documents should be unique to knitr, though.

Regards,
Yihui
--
Yihui Xie <xieyihui <at> gmail.com>
Phone: 515-294-2465 Web: http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA

On Tue, Oct 2, 2012 at 3:57 PM, Stephen Eglen <S.J.Eglen <at> damtp.cam.ac.uk> wrote:
>> I have just added knitr processor for Rnw files to the trunk. That is,
>> there is a customizable ess-swv-processor variable, which, if set to
>> 'knitr, makes "M-n s" to knit instead of Sweave, and "M-n T" to purl
>> instead of Stangle.
>>
>> There are also specialized ess-swv-knit and ess-swv-purl bound to "M-n
>> r" and "M-n u" exactly as in the above add-on by Simon Potter.
>
> Thanks Vitalie!
>
(Continue reading)

Stephen Eglen | 3 Oct 2012 11:05
Picon
Picon
Favicon

Re: knitr

> There is 100% guarantee for *.Rnw documents; one thing I can think of
> is to see if opts_chunk is used in the document, e.g.
> opts_chunk$set(echo = TRUE). This is unique to knitr. Other minor
> differences are like results='hide' (knitr) vs results=hide (Sweave).
>
> If a document uses \usepackage{Sweave}, it is more likely to be Sweave
> because knitr does not need this. The other approach is to check if
> (require('knitr')) in R before weaving the file.

Thanks Yihui.  (Is the word "no" missing before the 100% in your first
sentence?)

Stephen

______________________________________________
ESS-help <at> r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help

Yihui Xie | 3 Oct 2012 15:08
Favicon
Gravatar

Re: knitr

Oh, you are wright. Sorry about that..

Regards,
Yihui
--
Yihui Xie <xieyihui <at> gmail.com>
Phone: 515-294-2465 Web: http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA

On Wed, Oct 3, 2012 at 4:05 AM, Stephen Eglen <S.J.Eglen <at> damtp.cam.ac.uk> wrote:
>> There is 100% guarantee for *.Rnw documents; one thing I can think of
>> is to see if opts_chunk is used in the document, e.g.
>> opts_chunk$set(echo = TRUE). This is unique to knitr. Other minor
>> differences are like results='hide' (knitr) vs results=hide (Sweave).
>>
>> If a document uses \usepackage{Sweave}, it is more likely to be Sweave
>> because knitr does not need this. The other approach is to check if
>> (require('knitr')) in R before weaving the file.
>
> Thanks Yihui.  (Is the word "no" missing before the 100% in your first
> sentence?)
>
> Stephen
>

______________________________________________
ESS-help <at> r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help

(Continue reading)

Vitalie Spinu | 3 Oct 2012 11:37
Picon
Gravatar

Re: knitr

  >> Yihui Xie <xie <at> yihui.name>
  >> on Tue, 2 Oct 2012 16:05:57 -0500 wrote:

  > There is 100% guarantee for *.Rnw documents; one thing I can think of
  > is to see if opts_chunk is used in the document, e.g.
  > opts_chunk$set(echo = TRUE). This is unique to knitr. Other minor
  > differences are like results='hide' (knitr) vs results=hide (Sweave).

  > If a document uses \usepackage{Sweave}, it is more likely to be Sweave
  > because knitr does not need this. The other approach is to check if
  > (require('knitr')) in R before weaving the file.

A bit of a problem is that ess-swv-processor is a custom variable, and
is not good to mess with it programmaticaly. It's not good to ignore it
either if opts_chunk is present or knitr is loaded. 

To relatively quickly switch the processor one can do M-x set-variable RET
ess-s-pro TAB RET 'knitr RET. Alternatively people can just use
specialized shortcuts M-n r and M-n u, not a big deal.

[...]

  >> 
  >> I'm in a transition period -- I have several Sweave files, and think
  >> knitr is more flexible, so currently am writing new docs in knitr.

Yes, knitr is so much, much better and easier. Thanks Yihui. It's our
job now to correctly leverage the full power of knitr in ESS.

    Vitalie
(Continue reading)

Yihui Xie | 3 Oct 2012 15:13
Favicon
Gravatar

Re: knitr

I think a less intrusive way is to be able to set the R function as

(if (require('knitr')) knit else Sweave)

This is more flexible than choosing between knitr and sweave, e.g. the
user can set some global options before knit (like
opts_chunk$set(tidy=FALSE))

Regards,
Yihui
--
Yihui Xie <xieyihui <at> gmail.com>
Phone: 515-294-2465 Web: http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA

On Wed, Oct 3, 2012 at 4:37 AM, Vitalie Spinu <spinuvit <at> gmail.com> wrote:
>   >> Yihui Xie <xie <at> yihui.name>
>   >> on Tue, 2 Oct 2012 16:05:57 -0500 wrote:
>
>   > There is 100% guarantee for *.Rnw documents; one thing I can think of
>   > is to see if opts_chunk is used in the document, e.g.
>   > opts_chunk$set(echo = TRUE). This is unique to knitr. Other minor
>   > differences are like results='hide' (knitr) vs results=hide (Sweave).
>
>   > If a document uses \usepackage{Sweave}, it is more likely to be Sweave
>   > because knitr does not need this. The other approach is to check if
>   > (require('knitr')) in R before weaving the file.
>
> A bit of a problem is that ess-swv-processor is a custom variable, and
(Continue reading)

Vitalie Spinu | 3 Oct 2012 16:32
Picon
Gravatar

Re: knitr

  >> Yihui Xie <xie <at> yihui.name>
  >> on Wed, 3 Oct 2012 08:13:20 -0500 wrote:

  > I think a less intrusive way is to be able to set the R function as
  > (if (require('knitr')) knit else Sweave)

That can be, but would mean that there is no way to call Sweave when
knitr is loaded. I a bit undecided.

    Vitalie

______________________________________________
ESS-help <at> r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help

Yihui Xie | 3 Oct 2012 16:45
Favicon
Gravatar

Re: knitr

I mean that is the default value of ess-swv-processor, and it is still
customizable; if one wants to use Sweave, he can set it to
utils::Sweave

Regards,
Yihui
--
Yihui Xie <xieyihui <at> gmail.com>
Phone: 515-294-2465 Web: http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA

On Wed, Oct 3, 2012 at 9:32 AM, Vitalie Spinu <spinuvit <at> gmail.com> wrote:
>   >> Yihui Xie <xie <at> yihui.name>
>   >> on Wed, 3 Oct 2012 08:13:20 -0500 wrote:
>
>   > I think a less intrusive way is to be able to set the R function as
>   > (if (require('knitr')) knit else Sweave)
>
> That can be, but would mean that there is no way to call Sweave when
> knitr is loaded. I a bit undecided.
>
>     Vitalie

______________________________________________
ESS-help <at> r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help

Vitalie Spinu | 3 Oct 2012 16:49
Picon
Gravatar

Re: knitr

  >> Yihui Xie <xie <at> yihui.name>
  >> on Wed, 3 Oct 2012 09:45:11 -0500 wrote:

  > I mean that is the default value of ess-swv-processor, and it is still
  > customizable; if one wants to use Sweave, he can set it to
  > utils::Sweave

Ah, I see. Makes sense as a default, indeed. Will do that.

    Vitalie

  > On Wed, Oct 3, 2012 at 9:32 AM, Vitalie Spinu <spinuvit <at> gmail.com> wrote:
  >> >> Yihui Xie <xie <at> yihui.name>
  >> >> on Wed, 3 Oct 2012 08:13:20 -0500 wrote:
  >> 
  >> > I think a less intrusive way is to be able to set the R function as
  >> > (if (require('knitr')) knit else Sweave)
  >> 
  >> That can be, but would mean that there is no way to call Sweave when
  >> knitr is loaded. I a bit undecided.
  >> 
  >> Vitalie

______________________________________________
ESS-help <at> r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help

Kevin Wright | 2 Jun 2012 18:24
Picon

Re: knitr

I've used Sweave for many years, but have switched to knitr because I
find knitr makes several things _much_ easier.  I added this to my
.emacs:

(defun ess-knitr-weave ()
   "Run knitr on the current .Rnw file."
   (interactive)
   (ess-swv-run-in-R "knit"))
(define-key noweb-minor-mode-map "\M-nk" 'ess-knitr-weave)
(define-key noweb-minor-mode-map "\M-np" 'ess-swv-PDF)

With that change, I have a fairly simple two-step process to knit and
latex a file.

Slightly related to the discussion here, I wish I could change the
hard-to-type "#+" delimiter for org-mode.  Or, at least, make an
electric-# key similar to the electric-<.

Kevin

On Sat, Jun 2, 2012 at 4:01 AM, Stephen Eglen <S.J.Eglen <at> damtp.cam.ac.uk> wrote:
>
> With useR 2012 coming soon, can someone report back on what the
> community feels about packages like knitr, as an alternative to sweave?
> I see that Rstudio recently built in support for knitr, should we try
> the same for ESS?  Or is it too early to tell?
>
>  http://www.r-bloggers.com/new-version-of-rstudio-v0-96/
>
> Stephen
(Continue reading)

Stephen Eglen | 2 Jun 2012 21:25
Picon
Picon
Favicon

Re: knitr


> I've used Sweave for many years, but have switched to knitr because I
> find knitr makes several things _much_ easier.  

What sorts of things are easier?  Are these the types of things
mentioned on http://yihui.name/knitr/

> (defun ess-knitr-weave ()
>    "Run knitr on the current .Rnw file."
>    (interactive)
>    (ess-swv-run-in-R "knit"))
> (define-key noweb-minor-mode-map "\M-nk" 'ess-knitr-weave)
> (define-key noweb-minor-mode-map "\M-np" 'ess-swv-PDF)

Thanks!

> Slightly related to the discussion here, I wish I could change the
> hard-to-type "#+" delimiter for org-mode.  Or, at least, make an
> electric-# key similar to the electric-<.

I don't like the #+ syntax in org mode, my eyes still haven't adapted to
it.  But I don't think its likely to change.  Making an electric + key
should be straightforward, here's a simple version:

(defun electric-plus ()
  (interactive)
  (insert (if (= (current-column) 0) "#+" "+")))

Stephen

(Continue reading)

Michael Hannon | 2 Jun 2012 23:36
Picon
Favicon
Gravatar

Re: knitr

Stephen Eglen <S.J.Eglen <at> damtp.cam.ac.uk> wrote:
.
.
.

>> Slightly related to the discussion here, I wish I could change the
>> hard-to-type "#+" delimiter for org-mode.  Or, at least, make an
>> electric-# key similar to the electric-<.
>
> I don't like the #+ syntax in org mode, my eyes still haven't adapted to
> it.  But I don't think its likely to change.  Making an electric + key
> should be straightforward, here's a simple version:
>
>
> (defun electric-plus ()
>   (interactive)
>   (insert (if (= (current-column) 0) "#+" "+")))

If I understand correctly, this problem has already been solved:

    http://orgmode.org/manual/Easy-Templates.html#Easy-Templates

See also:

    https://github.com/capitaomorte/yasnippet

-- Mike

______________________________________________
ESS-help <at> r-project.org mailing list
(Continue reading)

Rasmus | 3 Jun 2012 20:08
Face
Picon

Re: knitr

Kevin Wright <kw.stat <at> gmail.com> writes:

> I've used Sweave for many years, but have switched to knitr because I
> find knitr makes several things _much_ easier.  I added this to my
> .emacs:

I like Knitr a lot and have written several papers with it.  It makes
including graphs easy.  I use noweb syntax.

However, I don't know if the <<KEYWORDS>> have stabilized.  It seems
they change every so often.  This might be taken into consideration
before implementing Knitr support.  That is unless Yihui says the syntax
has stabilized.

Here's what I use.  Knitr makes the .tex files and latexmk runs pdflatex
and Biber the appropriate number of times:

(add-hook 'Rnw-mode-hook
          (lambda ()
            (add-to-list 'TeX-command-list
                         '("knitr" "/home/rasmus/bin/knitr %s.Rnw %s.tex && latexmk -pdf %s.tex"
                           TeX-run-command nil the:help "Run Knitr") t)

            (setq TeX-command-default "Knitr")))

With the /home/rasmus/bin/knitr shipped with Knitr, i.e.

$ cat ~/bin/knitr 
#!/usr/bin/env Rscript

(Continue reading)

Yihui Xie | 6 Jun 2012 16:28
Favicon
Gravatar

Re: knitr

Thanks! I cannot say for sure the chunk options are stabilized now;
there is still small chance that I may add new options there (existing
options are unlikely to change in the future).

Do we have to know what is between << and >>= in order to add knitr
support in ESS? As the first step of the implementation, ESS may just
call library(knitr);knit(foo.Rnw) just like R CMD Sweave foo.Rnw.

Regards,
Yihui
--
Yihui Xie <xieyihui <at> gmail.com>
Phone: 515-294-2465 Web: http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA

On Sun, Jun 3, 2012 at 2:08 PM, Rasmus <rasmus <at> gmx.us> wrote:
>
> I like Knitr a lot and have written several papers with it.  It makes
> including graphs easy.  I use noweb syntax.
>
> However, I don't know if the <<KEYWORDS>> have stabilized.  It seems
> they change every so often.  This might be taken into consideration
> before implementing Knitr support.  That is unless Yihui says the syntax
> has stabilized.
>
> –Rasmus

______________________________________________
ESS-help <at> r-project.org mailing list
(Continue reading)

Rasmus | 6 Jun 2012 16:48
Face
Picon

Re: knitr


The following are just my opinions: 

> Do we have to know what is between << and >>= in order to add knitr
> support in ESS?

It doesn't need to, but I think there are quite a few options for Knitr,
also determining stuff like graphs, so it could be helpful.  Also, newer
iterations of ESS ship with auto-complete support, which could serve as
a nice interface.  How to do it smartly, I am not sure.  Ideally, I
guess it should just pick up whatever tags are supported 'live' (from
the 'Knitr bin' on the machine).

> As the first step of the implementation, ESS may just call
> library(knitr);knit(foo.Rnw) just like R CMD Sweave foo.Rnw.

Perhaps it would be better to just keep the generic `Sweave' + friends
buttons and make a customization option to choose either Knitr, Sweave
or something else.

--

-- 
And let me remind you also that moderation in the pursuit of justice
is no virtue

______________________________________________
ESS-help <at> r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help

Yihui Xie | 6 Jun 2012 16:54
Favicon
Gravatar

Re: knitr

When we were working on the auto-completion feature in RStudio, I
wrote an internal object in knitr for RStudio to use. See

str(knitr:::opts_chunk_attr)

This contains all default chunk options; hopefully ESS can use that as well.

For the second point, yes, that is also RStudio does.

Regards,
Yihui
--
Yihui Xie <xieyihui <at> gmail.com>
Phone: 515-294-2465 Web: http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA

On Wed, Jun 6, 2012 at 10:48 AM, Rasmus <rasmus <at> gmx.us> wrote:
>
> The following are just my opinions:
>
>> Do we have to know what is between << and >>= in order to add knitr
>> support in ESS?
>
> It doesn't need to, but I think there are quite a few options for Knitr,
> also determining stuff like graphs, so it could be helpful.  Also, newer
> iterations of ESS ship with auto-complete support, which could serve as
> a nice interface.  How to do it smartly, I am not sure.  Ideally, I
> guess it should just pick up whatever tags are supported 'live' (from
> the 'Knitr bin' on the machine).
(Continue reading)

Vitalie Spinu | 6 Jun 2012 22:11
Picon
Gravatar

Re: knitr


It looks like adding support to Rnw is a 30 minutes job. Adding Rhtml,
Rbrew, Rmd will require a bit of a rewrite of noweb which we plan
anyways. What is the state of the art in the noweb-for-emacs world?

Stephen, you have pointed once to an improved noweb mode. Was it this one:

 http://www.loveshack.ukfsn.org/emacs/noweb.el

  >> Yihui Xie <xie <at> yihui.name>
  >> on Wed, 6 Jun 2012 10:54:27 -0400 wrote:

  > When we were working on the auto-completion feature in RStudio, I
  > wrote an internal object in knitr for RStudio to use. See

  > str(knitr:::opts_chunk_attr)

This is great, thanks.  Would be also good to have explicit arguments
for functions like opts_knit$get().

  >>> As the first step of the implementation, ESS may just call
  >>> library(knitr);knit(foo.Rnw) just like R CMD Sweave foo.Rnw.
  >> 
  >> Perhaps it would be better to just keep the generic `Sweave' + friends
  >> buttons and make a customization option to choose either Knitr, Sweave
  >> or something else.

We need generic binding. Let's try not to add backend specific
keys. Ideally there would be one key (may be "M-n .") and a menu entry
to select a backend (be it sweave, knitr, pander, brew, or whatever
(Continue reading)

Stephen Eglen | 6 Jun 2012 22:21
Picon
Picon
Favicon

Re: knitr

> Stephen, you have pointed once to an improved noweb mode. Was it this one:
>
>  http://www.loveshack.ukfsn.org/emacs/noweb.el
yep, that's it; in that directory you'll also see multi-mode.el, which
provides the functionality for switching modes.  It is a whole heap
better than our old noweb.el, I've just not had the time to replace it
(it may also not work on XEmacs).

> Would be good to have a meaningful conventions. For example I think pdf
> output is preferred by most of the people and M-n p should rather give
> PDF output and not  ps. 
yep.

Stephen

______________________________________________
ESS-help <at> r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help

Vitalie Spinu | 7 Jun 2012 15:20
Picon
Gravatar

Re: knitr

  >> Stephen Eglen <S.J.Eglen <at> damtp.cam.ac.uk>
  >> on Wed, 06 Jun 2012 21:21:08 +0100 wrote:

  >> Stephen, you have pointed once to an improved noweb mode. Was it this one:
  >> 
  >> http://www.loveshack.ukfsn.org/emacs/noweb.elyep, that's it; in that directory you'll also see
multi-mode.el, which
  > provides the functionality for switching modes.  It is a whole heap
  > better than our old noweb.el, I've just not had the time to replace it
  > (it may also not work on XEmacs).

Right. I've checked it out. There are two main alternatives mmm-mode.el
and mumamo.el (part of NXhtml package), which are both restarting
submodes. We have already tried this with old noweb.el, and we clearly
don't want that.

Dave's multi-mode.el is amassing. I've just tried his noweb.el. The only
inconvenience is that there are many more associated indirect buffers
which appear in the buffer list.

Here is roughly how I see the road path. Write a mode litprog-mode with
generic "everything" (this will be a more or less a rewrite of Dave's
noweb.el).

Then derive lp-nw-mode, lp-md-mode, lp-brew-mode, lp-html-mode etc from
that. At the same time, build a customizable interface/structure to
encapsulate the processing backends.

There should be only one backend associated with a particular buffer and
all generic commands to dispatch to that backend.
(Continue reading)

Michael Lawrence | 6 Jun 2012 22:27

Re: knitr

On Wed, Jun 6, 2012 at 1:11 PM, Vitalie Spinu <spinuvit <at> gmail.com> wrote:

>
> It looks like adding support to Rnw is a 30 minutes job. Adding Rhtml,
> Rbrew, Rmd will require a bit of a rewrite of noweb which we plan
> anyways. What is the state of the art in the noweb-for-emacs world?
>
> Stephen, you have pointed once to an improved noweb mode. Was it this one:
>
>  http://www.loveshack.ukfsn.org/emacs/noweb.el
>
>
>  >> Yihui Xie <xie <at> yihui.name>
>   >> on Wed, 6 Jun 2012 10:54:27 -0400 wrote:
>
>  > When we were working on the auto-completion feature in RStudio, I
>  > wrote an internal object in knitr for RStudio to use. See
>
>  > str(knitr:::opts_chunk_attr)
>
> This is great, thanks.  Would be also good to have explicit arguments
> for functions like opts_knit$get().
>
>  >>> As the first step of the implementation, ESS may just call
>  >>> library(knitr);knit(foo.Rnw) just like R CMD Sweave foo.Rnw.
>  >>
>  >> Perhaps it would be better to just keep the generic `Sweave' + friends
>  >> buttons and make a customization option to choose either Knitr, Sweave
>  >> or something else.
>
(Continue reading)

Brett Presnell | 6 Jun 2012 22:58
Picon

Re: knitr


A comment, for whatever it's worth.

I have a lot more experience with AUCTeX and ESS than with org-mode, but
org-mode has at least one feature that I think is a big improvement over
editing Rnw files with AUCTeX + ESS + noweb + whatever-else-is-involved.
Code "chunks" in org-mode (delimited by #+BEGIN_SRC and #+END_SRC) can
be edited in a separate emacs window by typing C-c '.  This window is
opened in the appropriate mode (ESS for R code) and saved back to the
document by typing C-c ' again.

I'm not sure where the implementation would have to take place for Rnw
or knitr files (ESS?  AUCTeX?  Both?), but something like this would
avoid mode switching between AUCTeX and ESS, which has never worked
properly for me (maybe because I find it incredibly cumbersome to avoid
all use of dollar signs in my R code).  This may seem like a minor
thing, but these mode switching problems often make editing Rnw files
into a fairly painful experience for me, and I do a lot of it.

Does no one else have this problem anymore?

______________________________________________
ESS-help <at> r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help

Kevin Wright | 6 Jun 2012 23:01
Picon

Re: knitr

1. I also have problems with font-locking and key maps not always
working properly as I switch from code chunks and doc chunks.
2. "p" for PDF is a definite thumb-up.
3. There's also mmm-mode for multiple major modes.

Kevin

On Wed, Jun 6, 2012 at 3:58 PM, Brett Presnell <presnell <at> stat.ufl.edu> wrote:
>
> A comment, for whatever it's worth.
>
> I have a lot more experience with AUCTeX and ESS than with org-mode, but
> org-mode has at least one feature that I think is a big improvement over
> editing Rnw files with AUCTeX + ESS + noweb + whatever-else-is-involved.
> Code "chunks" in org-mode (delimited by #+BEGIN_SRC and #+END_SRC) can
> be edited in a separate emacs window by typing C-c '.  This window is
> opened in the appropriate mode (ESS for R code) and saved back to the
> document by typing C-c ' again.
>
> I'm not sure where the implementation would have to take place for Rnw
> or knitr files (ESS?  AUCTeX?  Both?), but something like this would
> avoid mode switching between AUCTeX and ESS, which has never worked
> properly for me (maybe because I find it incredibly cumbersome to avoid
> all use of dollar signs in my R code).  This may seem like a minor
> thing, but these mode switching problems often make editing Rnw files
> into a fairly painful experience for me, and I do a lot of it.
>
> Does no one else have this problem anymore?
>
> ______________________________________________
(Continue reading)

Rasmus | 6 Jun 2012 23:14
Face
Picon

Re: knitr

Brett Presnell <presnell <at> stat.ufl.edu> writes:

> Code "chunks" in org-mode (delimited by #+BEGIN_SRC and #+END_SRC) can
> be edited in a separate emacs window by typing C-c '.  This window is
> opened in the appropriate mode (ESS for R code) and saved back to the
> document by typing C-c ' again.

I love Org-mode, but I prefer the behavior of the ESS noweb mode.  It
would still be convenient for long code chucks, though.  I guess it
should be somewhat easy to write up a narrow to chuck function.

> I'm not sure where the implementation would have to take place for Rnw
> or knitr files (ESS?  AUCTeX?  Both?), but something like this would
> avoid mode switching between AUCTeX and ESS, which has never worked
> properly for me (maybe because I find it incredibly cumbersome to avoid
> all use of dollar signs in my R code).  This may seem like a minor
> thing, but these mode switching problems often make editing Rnw files
> into a fairly painful experience for me, and I do a lot of it.
>
> Does no one else have this problem anymore?

I sometimes have this problem, but not to often as I usually externalize
my R-code now¹.  If I have the problem I insert a line with
  % $
which solves the problem, but is tedious.

–Rasmus

Footnotes: 
¹  http://yihui.name/knitr/demo/externalization/
(Continue reading)

Vitalie Spinu | 7 Jun 2012 08:51
Picon
Gravatar

Re: knitr


Auctex integration is already there for Rnw, as far as I can see. You
can activate it from the noweb/Sweave menu. 

  >> Rasmus <rasmus <at> gmx.us>
  >> on Wed, 6 Jun 2012 22:14:44 +0100 wrote:

  > Brett Presnell <presnell <at> stat.ufl.edu> writes:
  >> Code "chunks" in org-mode (delimited by #+BEGIN_SRC and #+END_SRC) can
  >> be edited in a separate emacs window by typing C-c '.  This window is
  >> opened in the appropriate mode (ESS for R code) and saved back to the
  >> document by typing C-c ' again.

  > I love Org-mode, but I prefer the behavior of the ESS noweb mode.  It
  > would still be convenient for long code chucks, though.  I guess it
  > should be somewhat easy to write up a narrow to chuck function.

In noweb mode there is M-n n to narrow to chunks. It should eliminated
the need for C-c ' altogether. 

  >> I'm not sure where the implementation would have to take place for Rnw
  >> or knitr files (ESS?  AUCTeX?  Both?), but something like this would
  >> avoid mode switching between AUCTeX and ESS, which has never worked
  >> properly for me (maybe because I find it incredibly cumbersome to avoid
  >> all use of dollar signs in my R code).  This may seem like a minor
  >> thing, but these mode switching problems often make editing Rnw files
  >> into a fairly painful experience for me, and I do a lot of it.

Yes, resetting modes every time you switch a chunk is the main (if not
the only) reason for a rewrite.
(Continue reading)

Brett Presnell | 8 Jun 2012 18:27
Picon

Re: knitr


Vitalie Spinu <spinuvit <at> gmail.com> writes:

> Auctex integration is already there for Rnw, as far as I can see. You
> can activate it from the noweb/Sweave menu. 

Just to be clear, I knew this and have used AUCTeX/ESS for to edit Rnw
files years (and AUCTeX and S-mode/ESS separately since the early 90s).
It's just that the integration has never worked very well for me because
of the faulty mode switching.

> In noweb mode there is M-n n to narrow to chunks. It should eliminated
> the need for C-c ' altogether.

Thanks, that's good to know, although I'm not sure how much I can count
on it, given that emacs quickly gets into a state in which it's confused
about it's mode and what sort of chunk it's in.  

Hmmm, I notice that after typing M-n n I have to type M-n t twice to
turn off the narrowing.  Is that normal?  FWIW, I'm running GNU Emacs
24.1.50.1 (packaged by Damien Cassou) under Ubuntu 12.04 (Unity desktop)
with AUCTeX 11.86 and ESS 12.04-3.

> Yes, resetting modes every time you switch a chunk is the main (if not
> the only) reason for a rewrite.

Good to hear.  Thanks, and thanks to everyone for their efforts.

______________________________________________
ESS-help <at> r-project.org mailing list
(Continue reading)

Vitalie Spinu | 8 Jun 2012 21:50
Picon
Gravatar

Re: knitr


  > Hmmm, I notice that after typing M-n n I have to type M-n t twice to
  > turn off the narrowing.  Is that normal?  

No, M-n t is not toggling of narowing. It toggles the follow mode
(i.e. keeps dynamic narrowing to active code and documentation
chunks). To toggle narrowing off, use C-x n w (usual 'widen'
command). C-x n n does narrowing to region.

Vitalie.

______________________________________________
ESS-help <at> r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help

Daróczi Gergely | 11 Jun 2012 22:13
Gravatar

Re: knitr

Dear list members,

I've read above the discussion about multi-mode and just found a really
simple solution for the task for `brew` files, called:
two-mode-mode<http://www.welton.it/freesoftware/files/two-mode-mode.el>
.

This small `el` file checks for regexp separators and change mode from
"main" mode to "submodes" in a flash if the pointer is between tags. Works
really cool for brew files, I suppose it might be great for knitr/noweb
intergration too.

Best,
Gergely

On Fri, Jun 8, 2012 at 9:50 PM, Vitalie Spinu <spinuvit <at> gmail.com> wrote:

>
>
>  > Hmmm, I notice that after typing M-n n I have to type M-n t twice to
>  > turn off the narrowing.  Is that normal?
>
>
> No, M-n t is not toggling of narowing. It toggles the follow mode
> (i.e. keeps dynamic narrowing to active code and documentation
> chunks). To toggle narrowing off, use C-x n w (usual 'widen'
> command). C-x n n does narrowing to region.
>
> Vitalie.
>
(Continue reading)

Ken Williams | 22 Oct 2012 18:32

Re: knitr


> -----Original Message-----
> From: ess-help-bounces <at> r-project.org [mailto:ess-help-bounces <at> r-
> project.org] On Behalf Of Brett Presnell
> Sent: Wednesday, June 06, 2012 3:58 PM
> To: ess-help <at> stat.math.ethz.ch
> Subject: Re: [ESS] knitr
>
>
> A comment, for whatever it's worth.
>
> I have a lot more experience with AUCTeX and ESS than with org-mode, but
> org-mode has at least one feature that I think is a big improvement over
> editing Rnw files with AUCTeX + ESS + noweb + whatever-else-is-involved.

There's another quite major difference between org-mode and KnitR that I don't see mentioned very often. 
In org-mode, the chunks are executed (either on-demand or in bulk, like in KnitR) and then the output is
reinserted right back into the file.  So while you're editing the file, you can see all the parts that will
make up the final output.  The rendering from text to HTML (or to other formats) is then just a matter of
formatting all the content into the proper format, it doesn't (necessarily) run any of the code chunks.

This also means that the text version of the file can serve as a complete version of the document, without
needing to be re-executed again in the future.  A little bit like caching, but much more straightforward.

This workflow is probably the big thing that keeps me with org-mode rather than its various competitors.

 -Ken

CONFIDENTIALITY NOTICE: This e-mail message is for the s...{{dropped:7}}

(Continue reading)

Michael Lawrence | 23 Oct 2012 01:04

Re: knitr

Hi Ken,

I'm also a big fan of the "active document" approach of org-babel that
enables interactive, rather than batch mode, report generation. However, I
am frustrated by some usability issues, in particular the need to specify
the ":results output graphics" and then a ":file foo.png". The need for
:file is particularly annoying when all one wants is for the image to be
embedded into the report file.

I'm also thinking that it would be convenient to produce multiple outputs,
instead of a single report. For example, select plots and tables might land
in a streamlined report for a collaborator. Or result objects might be
serialized into a data package for sharing with other analysts.

I'm very close to taking on an extension of babel's R backend to make it as
convenient as knitr but with the interactive features. It would also
support multiple outputs via a report generator abstraction that could be
implemented for arbitrary targets.

Michael

On Mon, Oct 22, 2012 at 9:32 AM, Ken Williams
<Ken.Williams <at> windlogics.com>wrote:

>
>
> > -----Original Message-----
> > From: ess-help-bounces <at> r-project.org [mailto:ess-help-bounces <at> r-
> > project.org] On Behalf Of Brett Presnell
> > Sent: Wednesday, June 06, 2012 3:58 PM
(Continue reading)

Rasmus | 23 Oct 2012 03:44
Face
Picon

Re: knitr

Michael Lawrence <lawrence.michael <at> gene.com> writes:

> I'm also thinking that it would be convenient to produce multiple outputs,
> instead of a single report. For example, select plots and tables might land
> in a streamlined report for a collaborator.

You could do this using tag and write an script which excludes
different tags.  I.e. file.report.tex excludes headings with tag
collaborator while file.col.tex includes everything.  This should be
fairly easy with the 'new exporter'.

> I'm very close to taking on an extension of babel's R backend to make it as
> convenient as knitr but with the interactive features. It would also
> support multiple outputs via a report generator abstraction that could be
> implemented for arbitrary targets.

There's an approach that I like here

    https://github.com/chasberry/orgmode-accessories

I'm not sure whether it solves the graphics issues you mentioned.

–Rasmus

--

-- 
Got mashed potatoes. Ain't got no T-Bone. No T-Bone

______________________________________________
ESS-help <at> r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help
(Continue reading)

Michael Lawrence | 23 Oct 2012 04:06

Re: knitr

On Mon, Oct 22, 2012 at 6:44 PM, Rasmus <rasmus <at> gmx.us> wrote:

> Michael Lawrence <lawrence.michael <at> gene.com> writes:
>
> > I'm also thinking that it would be convenient to produce multiple
> outputs,
> > instead of a single report. For example, select plots and tables might
> land
> > in a streamlined report for a collaborator.
>
> You could do this using tag and write an script which excludes
> different tags.  I.e. file.report.tex excludes headings with tag
> collaborator while file.col.tex includes everything.  This should be
> fairly easy with the 'new exporter'.
>
> > I'm very close to taking on an extension of babel's R backend to make it
> as
> > convenient as knitr but with the interactive features. It would also
> > support multiple outputs via a report generator abstraction that could be
> > implemented for arbitrary targets.
>
> There's an approach that I like here
>
>     https://github.com/chasberry/orgmode-accessories
>
> I'm not sure whether it solves the graphics issues you mentioned.
>
>
Thanks, I've seen that. But what I want to do is much different. The idea
is to generate the reports incrementally and interactively using the active
(Continue reading)

Rasmus | 6 Jun 2012 23:04
Face
Picon

Re: knitr

Vitalie Spinu <spinuvit <at> gmail.com> writes:

> It looks like adding support to Rnw is a 30 minutes job. Adding Rhtml,
> Rbrew, Rmd will require a bit of a rewrite of noweb which we plan
> anyways. What is the state of the art in the noweb-for-emacs world?
>
> Stephen, you have pointed once to an improved noweb mode. Was it this one:
>
>  http://www.loveshack.ukfsn.org/emacs/noweb.el

Perhaps, if things are to be re-written anyway, alternatives such as the
MMM mode¹ should be considered.  I have no idea whether any of the
alternatives would be `better' than Loveshack's multi-mode.el +
noweb.el.

One of the things that is rather annoying about the current noweb mode
is that it forgets the state when going from LaTeX source to

In general for the completion system I, as suggested by my previous code
snip, favor the C-c C-c mechanism of AUCTeX over that of ESS-noweb (the
M-n keys).  If this is a generally held preference perhaps ESS could
specify a C-c C-c like menu with Sweave-like options.

I.e. in Knitr + LaTeX mode:
  C-c C-c brings up AUCTeX C-c C-c plus knitr option (default)

In Knitr + Markdown mode:
  C-c C-c brings up {`view in browser', `update html', ...}

This would allow for (i) easy key for output preparation; (ii) ido
(Continue reading)


Gmane