Changing style for the Sweave vignettes

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Changing style for the Sweave vignettes

January Weiner-3
As a user, I am always annoyed beyond measure that Sweave vignettes
precede the code by a command line prompt. It makes running examples
by simple copying of the commands from the vignette to the console a
pain. I know the idea is that it is clear what is the command, and
what is the output, but I'd rather precede the output with some kind
of marking.

Is there any other solution possible / allowed in vignettes? I would
much prefer to make my vignettes easier to use for people like me.

Kind regards,

j.

--
-------- January Weiner --------------------------------------

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Changing style for the Sweave vignettes

Søren Højsgaard-2
Not sure if this is the right list for your question, but

options("prompt"="")

should do it.

Regards
Søren

|-----Original Message-----
|From: [hidden email] [mailto:r-devel-bounces@r-
|project.org] On Behalf Of January Weiner
|Sent: 13. november 2014 12:10
|To: r-devel
|Subject: [Rd] Changing style for the Sweave vignettes
|
|As a user, I am always annoyed beyond measure that Sweave vignettes
|precede the code by a command line prompt. It makes running examples by
|simple copying of the commands from the vignette to the console a pain. I
|know the idea is that it is clear what is the command, and what is the
|output, but I'd rather precede the output with some kind of marking.
|
|Is there any other solution possible / allowed in vignettes? I would much
|prefer to make my vignettes easier to use for people like me.
|
|Kind regards,
|
|j.
|
|--
|-------- January Weiner --------------------------------------
|
|______________________________________________
|[hidden email] mailing list
|https://stat.ethz.ch/mailman/listinfo/r-devel

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Changing style for the Sweave vignettes

braverock
In reply to this post by January Weiner-3
On 11/13/2014 05:09 AM, January Weiner wrote:
> As a user, I am always annoyed beyond measure that Sweave vignettes
> precede the code by a command line prompt. It makes running examples
> by simple copying of the commands from the vignette to the console a
> pain. I know the idea is that it is clear what is the command, and
> what is the output, but I'd rather precede the output with some kind
> of marking.
>
> Is there any other solution possible / allowed in vignettes? I would
> much prefer to make my vignettes easier to use for people like me.

I agree with Søren that this is not the right list, but to complete the
thread...

See the examples in

?vignette

start just above

## Now let us have a closer look at the code

All vignette's are compiled.  You can trivially extract all the code
used for any vignette in R, including any code not displayed in the text
and hidden from the user, from within R, or saved out to an editor so
you can source it line by line from Rstudio (or vim or emacs or...).
That's the whole point.

Regards,

Brian

--
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Changing style for the Sweave vignettes

January Weiner-3
Thank you, Søren and Brian for your answers.

Whether this is the right list -- well, I think it is, since I am
developing a package and would like to create a vignette which is
useful and convenient for my users. I know how to extract the vignette
code. However, most of my users don't.  Or if they do, they do not
bother, but copy the examples from the PDF while they are reading it.
At least that is my observation.

I'm sorry that my e-mail was unclear -- I started my e-mail with "as a
user, ...", but I did mention that it is my vignettes that I am
concerned with.

options(prompt=...) is an idea, though I'm still not sure as to the
second part of my question - whether a vignette without a command
prompt is acceptable in a package or not.

Kind regards,

j.


On 13 November 2014 12:36, Brian G. Peterson <[hidden email]> wrote:

> On 11/13/2014 05:09 AM, January Weiner wrote:
>>
>> As a user, I am always annoyed beyond measure that Sweave vignettes
>> precede the code by a command line prompt. It makes running examples
>> by simple copying of the commands from the vignette to the console a
>> pain. I know the idea is that it is clear what is the command, and
>> what is the output, but I'd rather precede the output with some kind
>> of marking.
>>
>> Is there any other solution possible / allowed in vignettes? I would
>> much prefer to make my vignettes easier to use for people like me.
>
>
> I agree with Søren that this is not the right list, but to complete the
> thread...
>
> See the examples in
>
> ?vignette
>
> start just above
>
> ## Now let us have a closer look at the code
>
> All vignette's are compiled.  You can trivially extract all the code used
> for any vignette in R, including any code not displayed in the text and
> hidden from the user, from within R, or saved out to an editor so you can
> source it line by line from Rstudio (or vim or emacs or...). That's the
> whole point.
>
> Regards,
>
> Brian
>
> --
> Brian G. Peterson
> http://braverock.com/brian/
> Ph: 773-459-4973
> IM: bgpbraverock
>
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



--
-------- January Weiner --------------------------------------

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Changing style for the Sweave vignettes

Martin Morgan-2
In reply to this post by January Weiner-3
On 11/13/2014 03:09 AM, January Weiner wrote:
> As a user, I am always annoyed beyond measure that Sweave vignettes
> precede the code by a command line prompt. It makes running examples
> by simple copying of the commands from the vignette to the console a
> pain. I know the idea is that it is clear what is the command, and
> what is the output, but I'd rather precede the output with some kind
> of marking.
>
> Is there any other solution possible / allowed in vignettes? I would
> much prefer to make my vignettes easier to use for people like me.

Vignettes do not need to be generated by Sweave and to pdf documents. My current
favorite (e.g., recent course material at
http://bioconductor.org/help/course-materials/ which uses styling from the
BiocStyle package
http://bioconductor.org/packages/release/bioc/html/BiocStyle.html) uses the
knitr package (see http://yihui.name/knitr/) to produce HTML vignettes (knitr
will also process Rnw files to pdf with perhaps more appealing styling, see,
e.g.,  http://bit.ly/117OLVl for an example of PDF output).

The mechanics are discussed in Writing R Extensions (RShowDoc('R-exts')),
section 1.4.2 Non-Sweave vignettes. There are three steps involved: specifying a
\VignetteEngine in the vignette itself, specifying VignetteBuilder: field in the
DESCRIPTION file, and including the package providing the engine (knitr, in my
case) in the Suggests: field of the DESCRIPTION file.

Brian mentioned processing the vignette to it's underlying code; see
?browseVignettes and ?vignette for installed packages, and ?Stangle in R and R
CMD Stangle for extracting the R code from stand-alone vignettes to .R files.

Martin Morgan

>
> Kind regards,
>
> j.
>


--
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109

Location: Arnold Building M1 B861
Phone: (206) 667-2793

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Changing style for the Sweave vignettes

Paul Gilbert-2
In reply to this post by January Weiner-3
You might also consider starting your vignettes with

\begin{Scode}{echo=FALSE,results=hide}
  options(continue="  ")
\end{Scode}

Then you get one prompt but it is still easy to cut and paste. This has
been in many of my packages for many years, so I think it would be fair
to assume it is acceptable.

Paul

On 11/13/2014 06:56 AM, January Weiner wrote:

> Thank you, Søren and Brian for your answers.
>
> Whether this is the right list -- well, I think it is, since I am
> developing a package and would like to create a vignette which is
> useful and convenient for my users. I know how to extract the vignette
> code. However, most of my users don't.  Or if they do, they do not
> bother, but copy the examples from the PDF while they are reading it.
> At least that is my observation.
>
> I'm sorry that my e-mail was unclear -- I started my e-mail with "as a
> user, ...", but I did mention that it is my vignettes that I am
> concerned with.
>
> options(prompt=...) is an idea, though I'm still not sure as to the
> second part of my question - whether a vignette without a command
> prompt is acceptable in a package or not.
>
> Kind regards,
>
> j.
>
>
> On 13 November 2014 12:36, Brian G. Peterson <[hidden email]> wrote:
>> On 11/13/2014 05:09 AM, January Weiner wrote:
>>>
>>> As a user, I am always annoyed beyond measure that Sweave vignettes
>>> precede the code by a command line prompt. It makes running examples
>>> by simple copying of the commands from the vignette to the console a
>>> pain. I know the idea is that it is clear what is the command, and
>>> what is the output, but I'd rather precede the output with some kind
>>> of marking.
>>>
>>> Is there any other solution possible / allowed in vignettes? I would
>>> much prefer to make my vignettes easier to use for people like me.
>>
>>
>> I agree with Søren that this is not the right list, but to complete the
>> thread...
>>
>> See the examples in
>>
>> ?vignette
>>
>> start just above
>>
>> ## Now let us have a closer look at the code
>>
>> All vignette's are compiled.  You can trivially extract all the code used
>> for any vignette in R, including any code not displayed in the text and
>> hidden from the user, from within R, or saved out to an editor so you can
>> source it line by line from Rstudio (or vim or emacs or...). That's the
>> whole point.
>>
>> Regards,
>>
>> Brian
>>
>> --
>> Brian G. Peterson
>> http://braverock.com/brian/
>> Ph: 773-459-4973
>> IM: bgpbraverock
>>
>>
>> ______________________________________________
>> [hidden email] mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Changing style for the Sweave vignettes

January Weiner-3
Dear Paul and Martin,

thanks for the useful tips. I'll start with Paul's suggestion (getting
rid of these '+'-es will already be a boon!), and move from my old
Sweave vignettes when possible.

Thank you!
j.

On 13 November 2014 15:35, Paul Gilbert <[hidden email]> wrote:

> You might also consider starting your vignettes with
>
> \begin{Scode}{echo=FALSE,results=hide}
>  options(continue="  ")
> \end{Scode}
>
> Then you get one prompt but it is still easy to cut and paste. This has been
> in many of my packages for many years, so I think it would be fair to assume
> it is acceptable.
>
> Paul
>
>
> On 11/13/2014 06:56 AM, January Weiner wrote:
>>
>> Thank you, Søren and Brian for your answers.
>>
>> Whether this is the right list -- well, I think it is, since I am
>> developing a package and would like to create a vignette which is
>> useful and convenient for my users. I know how to extract the vignette
>> code. However, most of my users don't.  Or if they do, they do not
>> bother, but copy the examples from the PDF while they are reading it.
>> At least that is my observation.
>>
>> I'm sorry that my e-mail was unclear -- I started my e-mail with "as a
>> user, ...", but I did mention that it is my vignettes that I am
>> concerned with.
>>
>> options(prompt=...) is an idea, though I'm still not sure as to the
>> second part of my question - whether a vignette without a command
>> prompt is acceptable in a package or not.
>>
>> Kind regards,
>>
>> j.
>>
>>
>> On 13 November 2014 12:36, Brian G. Peterson <[hidden email]> wrote:
>>>
>>> On 11/13/2014 05:09 AM, January Weiner wrote:
>>>>
>>>>
>>>> As a user, I am always annoyed beyond measure that Sweave vignettes
>>>> precede the code by a command line prompt. It makes running examples
>>>> by simple copying of the commands from the vignette to the console a
>>>> pain. I know the idea is that it is clear what is the command, and
>>>> what is the output, but I'd rather precede the output with some kind
>>>> of marking.
>>>>
>>>> Is there any other solution possible / allowed in vignettes? I would
>>>> much prefer to make my vignettes easier to use for people like me.
>>>
>>>
>>>
>>> I agree with Søren that this is not the right list, but to complete the
>>> thread...
>>>
>>> See the examples in
>>>
>>> ?vignette
>>>
>>> start just above
>>>
>>> ## Now let us have a closer look at the code
>>>
>>> All vignette's are compiled.  You can trivially extract all the code used
>>> for any vignette in R, including any code not displayed in the text and
>>> hidden from the user, from within R, or saved out to an editor so you can
>>> source it line by line from Rstudio (or vim or emacs or...). That's the
>>> whole point.
>>>
>>> Regards,
>>>
>>> Brian
>>>
>>> --
>>> Brian G. Peterson
>>> http://braverock.com/brian/
>>> Ph: 773-459-4973
>>> IM: bgpbraverock
>>>
>>>
>>> ______________________________________________
>>> [hidden email] mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
>>
>>
>>
>



--
-------- January Weiner --------------------------------------

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Changing style for the Sweave vignettes

Yihui Xie-2
As someone who was also annoyed by command line prompts a couple of
years ago, I wrote knitr and removed prompts as well as the
continuation characters (+) by default (FAQ5:
https://github.com/yihui/knitr/blob/master/FAQ.md).

BTW, I do not always trust copying text from PDF. Perhaps it is fine
for code/text in verbatim environments (as Paul indicated above).
LaTeX users are probably aware of ligatures (e.g. for "ff") and the
fact that leading/trailing white spaces are often removed in the PDF
output, which will make "What You Copy is Not What You Get".
Personally I think HTML is more reliable in this respect (<pre></pre>
is more faithful), and this is one of the reasons that I'm in favor of
HTML vignettes instead of PDF when I do not care that much about
precise typesetting (which is not always the most important thing).

Regards,
Yihui
--
Yihui Xie <[hidden email]>
Web: http://yihui.name


On Thu, Nov 13, 2014 at 10:10 AM, January Weiner
<[hidden email]> wrote:

> Dear Paul and Martin,
>
> thanks for the useful tips. I'll start with Paul's suggestion (getting
> rid of these '+'-es will already be a boon!), and move from my old
> Sweave vignettes when possible.
>
> Thank you!
> j.
>
> On 13 November 2014 15:35, Paul Gilbert <[hidden email]> wrote:
>> You might also consider starting your vignettes with
>>
>> \begin{Scode}{echo=FALSE,results=hide}
>>  options(continue="  ")
>> \end{Scode}
>>
>> Then you get one prompt but it is still easy to cut and paste. This has been
>> in many of my packages for many years, so I think it would be fair to assume
>> it is acceptable.
>>
>> Paul
>>
>>
>> On 11/13/2014 06:56 AM, January Weiner wrote:
>>>
>>> Thank you, Søren and Brian for your answers.
>>>
>>> Whether this is the right list -- well, I think it is, since I am
>>> developing a package and would like to create a vignette which is
>>> useful and convenient for my users. I know how to extract the vignette
>>> code. However, most of my users don't.  Or if they do, they do not
>>> bother, but copy the examples from the PDF while they are reading it.
>>> At least that is my observation.
>>>
>>> I'm sorry that my e-mail was unclear -- I started my e-mail with "as a
>>> user, ...", but I did mention that it is my vignettes that I am
>>> concerned with.
>>>
>>> options(prompt=...) is an idea, though I'm still not sure as to the
>>> second part of my question - whether a vignette without a command
>>> prompt is acceptable in a package or not.
>>>
>>> Kind regards,
>>>
>>> j.
>>>
>>>
>>> On 13 November 2014 12:36, Brian G. Peterson <[hidden email]> wrote:
>>>>
>>>> On 11/13/2014 05:09 AM, January Weiner wrote:
>>>>>
>>>>>
>>>>> As a user, I am always annoyed beyond measure that Sweave vignettes
>>>>> precede the code by a command line prompt. It makes running examples
>>>>> by simple copying of the commands from the vignette to the console a
>>>>> pain. I know the idea is that it is clear what is the command, and
>>>>> what is the output, but I'd rather precede the output with some kind
>>>>> of marking.
>>>>>
>>>>> Is there any other solution possible / allowed in vignettes? I would
>>>>> much prefer to make my vignettes easier to use for people like me.
>>>>
>>>>
>>>>
>>>> I agree with Søren that this is not the right list, but to complete the
>>>> thread...
>>>>
>>>> See the examples in
>>>>
>>>> ?vignette
>>>>
>>>> start just above
>>>>
>>>> ## Now let us have a closer look at the code
>>>>
>>>> All vignette's are compiled.  You can trivially extract all the code used
>>>> for any vignette in R, including any code not displayed in the text and
>>>> hidden from the user, from within R, or saved out to an editor so you can
>>>> source it line by line from Rstudio (or vim or emacs or...). That's the
>>>> whole point.
>>>>
>>>> Regards,
>>>>
>>>> Brian
>>>>
>>>> --
>>>> Brian G. Peterson
>>>> http://braverock.com/brian/
>>>> Ph: 773-459-4973
>>>> IM: bgpbraverock

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel