Re: [Rd] R CMD check and error in an \Sexpr in an Rd file

2011-11-03 Thread Renaud Gaujoux
Georgi, I tried with paste() instead of cat(), but I then get the 
following in my PDF manual:


[1] "line\nnext line"

i.e. what would be printed in the R console, which is not what I want.
I would like to get something like this in the Latex code:

\begin{verbatim}
line
next line
\end{verbatim}

Using cat() I get the following in the Latex code:

\AsIs{
line
next line}

which does not render as a new line in the PDF and breaks if empty lines 
are present in the output text.
Besides it will also break on \Sexpr[results=verbatim, 
stage=render]{list("text", 3)}.


But maybe this is not what 'results=verbatim' is supposed to do nor to 
be used for?


Renaud

Another test Rd file.

%
\name{Sexpr}
\alias{Sexpr}
\title{Error and verbatim in Sexpr}
\description{
   Testing Sexpr in Rd files

   %\Sexpr[results=verbatim, stage=render]{stop("error in sexpr")}

   Verbatim:

   1: \Sexpr[results=verbatim, stage=render]{cat("line\nnext line\n")}

   2: \Sexpr[results=verbatim, stage=render]{"line\nnext line\n"}

   3: \Sexpr[results=verbatim, stage=render]{list("line\nnext line", 3)}

   Text:

   1: \Sexpr[results=text, stage=render]{cat("line\nnext line\n")}

   2: \Sexpr[results=text, stage=render]{"line\nnext line\n"}

   3: \Sexpr[results=text, stage=render]{list("line\nnext line", 3)}

}
%

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] R CMD check and error in an \Sexpr in an Rd file

2011-11-03 Thread Duncan Murdoch

On 11-11-03 7:58 AM, Renaud Gaujoux wrote:

Georgi, I tried with paste() instead of cat(), but I then get the
following in my PDF manual:

[1] "line\nnext line"

i.e. what would be printed in the R console, which is not what I want.
I would like to get something like this in the Latex code:

\begin{verbatim}
line
next line
\end{verbatim}


I don't think you want that:  it forces display mode.  You might want 
verbatim text displayed inline, like \verb does.




Using cat() I get the following in the Latex code:

\AsIs{
line
next line}

which does not render as a new line in the PDF and breaks if empty lines
are present in the output text.


So the problem is with the \AsIs macro.  You can see the definition in 
the Rd.sty file in R_HOME/share/texmf/tex/latex.  Can you suggest an 
improvement?


Duncan Murdoch


Besides it will also break on \Sexpr[results=verbatim,
stage=render]{list("text", 3)}.

But maybe this is not what 'results=verbatim' is supposed to do nor to
be used for?

Renaud

Another test Rd file.

%
\name{Sexpr}
\alias{Sexpr}
\title{Error and verbatim in Sexpr}
\description{
 Testing Sexpr in Rd files

 %\Sexpr[results=verbatim, stage=render]{stop("error in sexpr")}

 Verbatim:

 1: \Sexpr[results=verbatim, stage=render]{cat("line\nnext line\n")}

 2: \Sexpr[results=verbatim, stage=render]{"line\nnext line\n"}

 3: \Sexpr[results=verbatim, stage=render]{list("line\nnext line", 3)}

 Text:

 1: \Sexpr[results=text, stage=render]{cat("line\nnext line\n")}

 2: \Sexpr[results=text, stage=render]{"line\nnext line\n"}

 3: \Sexpr[results=text, stage=render]{list("line\nnext line", 3)}

}
%

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] R CMD check and error in an \Sexpr in an Rd file

2011-11-03 Thread Renaud Gaujoux
Although I use Latex quite a lot, I am not literate in Latex macro 
languages (e.g. the definition of AsIs).
Is there (I am sure there is) a reason why a plain verbatim environment 
is not used in this case?



On 03/11/2011 14:19, Duncan Murdoch wrote:

On 11-11-03 7:58 AM, Renaud Gaujoux wrote:

Georgi, I tried with paste() instead of cat(), but I then get the
following in my PDF manual:

[1] "line\nnext line"

i.e. what would be printed in the R console, which is not what I want.
I would like to get something like this in the Latex code:

\begin{verbatim}
line
next line
\end{verbatim}


I don't think you want that:  it forces display mode.  You might want 
verbatim text displayed inline, like \verb does.




Using cat() I get the following in the Latex code:

\AsIs{
line
next line}

which does not render as a new line in the PDF and breaks if empty lines
are present in the output text.


So the problem is with the \AsIs macro.  You can see the definition in 
the Rd.sty file in R_HOME/share/texmf/tex/latex.  Can you suggest an 
improvement?


Duncan Murdoch


Besides it will also break on \Sexpr[results=verbatim,
stage=render]{list("text", 3)}.

But maybe this is not what 'results=verbatim' is supposed to do nor to
be used for?

Renaud

Another test Rd file.

%
\name{Sexpr}
\alias{Sexpr}
\title{Error and verbatim in Sexpr}
\description{
 Testing Sexpr in Rd files

 %\Sexpr[results=verbatim, stage=render]{stop("error in sexpr")}

 Verbatim:

 1: \Sexpr[results=verbatim, stage=render]{cat("line\nnext line\n")}

 2: \Sexpr[results=verbatim, stage=render]{"line\nnext line\n"}

 3: \Sexpr[results=verbatim, stage=render]{list("line\nnext 
line", 3)}


 Text:

 1: \Sexpr[results=text, stage=render]{cat("line\nnext line\n")}

 2: \Sexpr[results=text, stage=render]{"line\nnext line\n"}

 3: \Sexpr[results=text, stage=render]{list("line\nnext line", 3)}

}
%

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel




__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] R CMD check and error in an \Sexpr in an Rd file

2011-11-03 Thread Georgi Boshnakov
Dear Duncan and Renauld,


The error caused by the empty line(s) can be removed by prefixin the macro with 
\long
in Rd.sty:

\long\def\Rd@AsIsX#1{\normalfont #1\egroup}

but the slash-n's come up in the output. 

In "text mode" this seems not to be a problem. Following normal TeX rules one 
needs to enter an empty line, e.g. by \n\n.

Having written that, I tried putting two \n's in the verbatim text and it seems 
to work (see below).

I need to consult the TeX book to be sure but the
problem with AsIs seems to be that by the time it starts processing its 
argument it has been tokenized by TeX
(hence single newlines have become spaces). 

Further thought may be needed about the new lines in verbatim. 
I may have missed again something but it seems that the observed output is 
consistent with the 
documentation, which states:

"results=verbatim Print the results of the code just as if it was executed 
at the
console, and include the printed results verbatim. (Invisible results will 
not print.)"

And the examples print on the console as they appear in output (with print, not 
cat).

Do we need exception from the general rule? 

An alternative would be to introduce results=verbatimLines option. 


Georgi

\name{Sexpr}
\alias{Sexpr}
\title{Error and verbatim in Sexpr}
\description{
Testing Sexpr in Rd files

%\Sexpr[results=verbatim, stage=render]{stop("error in sexpr")}

Verbatim:

1: \Sexpr[results=verbatim, stage=render]{cat("line\n\nnext line\n\n and 
another")}

%1a: \Sexpr[results=text, stage=render]{capture.output(cat(c("line", "next 
line\n"),sep="\n", collapse="\n"))}

2: \Sexpr[results=verbatim, stage=render]{"line\nnext line\n"}

3: \Sexpr[results=verbatim, stage=render]{list("line\nnext line", 3)}

4: \Sexpr[results=verbatim, stage=render]{list(c("line", "next line"), 3)}

Text:

1: \Sexpr[results=text, stage=render]{cat("line\nnext line\n")}

2: \Sexpr[results=text, stage=render]{"line\nnext line\n"}

3: \Sexpr[results=text, stage=render]{list("line\n\nnext  line 
newline and another", 3)}

}



--
Dr Georgi Boshnakov   tel: (+44) (0)161 306 3684
School of Mathematics fax: (+44) (0)161 306 3669
Alan Turing Building 1.125
The University of Manchester  email: georgi.boshna...@manchester.ac.uk
Oxford Road
Manchester M13 9PL
UK



From: Duncan Murdoch [murdoch.dun...@gmail.com]
Sent: 03 November 2011 12:19
To: Renaud Gaujoux
Cc: Georgi Boshnakov; r-devel@r-project.org
Subject: Re: [Rd] R CMD check and error in an \Sexpr in an Rd file

On 11-11-03 7:58 AM, Renaud Gaujoux wrote:
> Georgi, I tried with paste() instead of cat(), but I then get the
> following in my PDF manual:
>
> [1] "line\nnext line"
>
> i.e. what would be printed in the R console, which is not what I want.
> I would like to get something like this in the Latex code:
>
> \begin{verbatim}
> line
> next line
> \end{verbatim}

I don't think you want that:  it forces display mode.  You might want
verbatim text displayed inline, like \verb does.

>
> Using cat() I get the following in the Latex code:
>
> \AsIs{
> line
> next line}
>
> which does not render as a new line in the PDF and breaks if empty lines
> are present in the output text.

So the problem is with the \AsIs macro.  You can see the definition in
the Rd.sty file in R_HOME/share/texmf/tex/latex.  Can you suggest an
improvement?

Duncan Murdoch

> Besides it will also break on \Sexpr[results=verbatim,
> stage=render]{list("text", 3)}.
>
> But maybe this is not what 'results=verbatim' is supposed to do nor to
> be used for?
>
> Renaud
>
> Another test Rd file.
>
> %
> \name{Sexpr}
> \alias{Sexpr}
> \title{Error and verbatim in Sexpr}
> \description{
>  Testing Sexpr in Rd files
>
>  %\Sexpr[results=verbatim, stage=render]{stop("error in sexpr")}
>
>  Verbatim:
>
>  1: \Sexpr[results=verbatim, stage=render]{cat("line\nnext line\n")}
>
>  2: \Sexpr[results=verbatim, stage=render]{"line\nnext line\n"}
>
>  3: \Sexpr[results=verbatim, stage=render]{list("line\nnext line", 3)}
>
>  Text:
>
>  1: \Sexpr[results=text, stage=render]{cat("line\nnext line\n")}
>
>  2: \Sexpr[results=text, stage=render]{"line\nnext line\n"}
>
>  3: \Sexpr[results=text, stage=render]{list("line\nnext line", 3)}
>
> }
> %
>
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel


__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] How to test package on Solaris

2011-11-03 Thread William Revelle
Dear R developers,

Is there a way to pretest a package on the Solaris-sparc and solaris-x86 
systems equivalent to the win-builder check?

My psych package (1.1.10 and 1.1.11) passes all checks for the Mac on my 
system, on the win-builder checking system supported by Uwe, and then passes 
Kurt's tests to install on CRAN.  But it then fails when being built for the 
solaris systems.  

Rather than burden Kurt and Uwe and the whole CRAN distribution process with 
frequent attempts to fix the problem, it would be preferable if I could pretest 
on a solaris system and then upload the final result.

I note from reading past queries to the list that this question has been asked 
before and the solution seems to have been some nice soul  volunteering to test 
a particular package.  A more general solution would seem preferred, if this is 
possible.

Thanks.

Bill



William Revellehttp://personality-project.org/revelle.html
Professor  http://personality-project.org
Department of Psychology   http://www.wcas.northwestern.edu/psych/
Northwestern Universityhttp://www.northwestern.edu/
Use R for psychology http://personality-project.org/r
It is 6 minutes to midnighthttp://www.thebulletin.org

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] R CMD check and error in an \Sexpr in an Rd file

2011-11-03 Thread Renaud Gaujoux

Thank you Georgi.
With the fix \long the output is indeed consistent with the documentation.
I think my use of cat() worked by luck as its output should not have 
been rendered.


Would a 'results=tex' (html, text) be possible? or 'results=source' that 
could be combined with \if{format}{text}?
This would allow to generate custom Latex, or HTML code, but it might 
also be is hazardous...


Renaud

--
Renaud Gaujoux
Computational Biology - University of Cape Town
South Africa


On 03/11/2011 15:50, Georgi Boshnakov wrote:

Dear Duncan and Renauld,


The error caused by the empty line(s) can be removed by prefixin the macro with 
\long
in Rd.sty:

\long\def\Rd@AsIsX#1{\normalfont #1\egroup}

but the slash-n's come up in the output.

In "text mode" this seems not to be a problem. Following normal TeX rules one 
needs to enter an empty line, e.g. by \n\n.

Having written that, I tried putting two \n's in the verbatim text and it seems 
to work (see below).

I need to consult the TeX book to be sure but the
problem with AsIs seems to be that by the time it starts processing its 
argument it has been tokenized by TeX
(hence single newlines have become spaces).

Further thought may be needed about the new lines in verbatim.
I may have missed again something but it seems that the observed output is 
consistent with the
documentation, which states:

 "results=verbatim Print the results of the code just as if it was executed 
at the
 console, and include the printed results verbatim. (Invisible results will not 
print.)"

And the examples print on the console as they appear in output (with print, not 
cat).

Do we need exception from the general rule?

An alternative would be to introduce results=verbatimLines option.


Georgi

\name{Sexpr}
\alias{Sexpr}
\title{Error and verbatim in Sexpr}
\description{
 Testing Sexpr in Rd files

 %\Sexpr[results=verbatim, stage=render]{stop("error in sexpr")}

 Verbatim:

 1: \Sexpr[results=verbatim, stage=render]{cat("line\n\nnext line\n\n and 
another")}

%1a: \Sexpr[results=text, stage=render]{capture.output(cat(c("line", "next 
line\n"),sep="\n", collapse="\n"))}

 2: \Sexpr[results=verbatim, stage=render]{"line\nnext line\n"}

 3: \Sexpr[results=verbatim, stage=render]{list("line\nnext line", 3)}

 4: \Sexpr[results=verbatim, stage=render]{list(c("line", "next line"), 3)}

 Text:

 1: \Sexpr[results=text, stage=render]{cat("line\nnext line\n")}

 2: \Sexpr[results=text, stage=render]{"line\nnext line\n"}

 3: \Sexpr[results=text, stage=render]{list("line\n\nnext  line 
newline and another", 3)}

}



--
Dr Georgi Boshnakov   tel: (+44) (0)161 306 3684
School of Mathematics fax: (+44) (0)161 306 3669
Alan Turing Building 1.125
The University of Manchester  email: georgi.boshna...@manchester.ac.uk
Oxford Road
Manchester M13 9PL
UK



From: Duncan Murdoch [murdoch.dun...@gmail.com]
Sent: 03 November 2011 12:19
To: Renaud Gaujoux
Cc: Georgi Boshnakov; r-devel@r-project.org
Subject: Re: [Rd] R CMD check and error in an \Sexpr in an Rd file

On 11-11-03 7:58 AM, Renaud Gaujoux wrote:

Georgi, I tried with paste() instead of cat(), but I then get the
following in my PDF manual:

[1] "line\nnext line"

i.e. what would be printed in the R console, which is not what I want.
I would like to get something like this in the Latex code:

\begin{verbatim}
line
next line
\end{verbatim}

I don't think you want that:  it forces display mode.  You might want
verbatim text displayed inline, like \verb does.


Using cat() I get the following in the Latex code:

\AsIs{
line
next line}

which does not render as a new line in the PDF and breaks if empty lines
are present in the output text.

So the problem is with the \AsIs macro.  You can see the definition in
the Rd.sty file in R_HOME/share/texmf/tex/latex.  Can you suggest an
improvement?

Duncan Murdoch


Besides it will also break on \Sexpr[results=verbatim,
stage=render]{list("text", 3)}.

But maybe this is not what 'results=verbatim' is supposed to do nor to
be used for?

Renaud

Another test Rd file.

%
\name{Sexpr}
\alias{Sexpr}
\title{Error and verbatim in Sexpr}
\description{
  Testing Sexpr in Rd files

  %\Sexpr[results=verbatim, stage=render]{stop("error in sexpr")}

  Verbatim:

  1: \Sexpr[results=verbatim, stage=render]{cat("line\nnext line\n")}

  2: \Sexpr[results=verbatim, stage=render]{"line\nnext line\n"}

  3: \Sexpr[results=verbatim, stage=render]{list("line\nnext line", 3)}

  Text:

  1: \Sexpr[results=text, stage=render]{cat("line\nnext line\n")}

  2: \Sexpr[results=text, stage=render]{"line\nnext line\n"}

  3: \Sexpr[results=text, stage=render]{list("line\nnext line", 3)}

}
%

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


__

Re: [Rd] R CMD check and error in an \Sexpr in an Rd file

2011-11-03 Thread Duncan Murdoch

On 03/11/2011 10:21 AM, Renaud Gaujoux wrote:

Thank you Georgi.
With the fix \long the output is indeed consistent with the documentation.
I think my use of cat() worked by luck as its output should not have
been rendered.

Would a 'results=tex' (html, text) be possible? or 'results=source' that
could be combined with \if{format}{text}?
This would allow to generate custom Latex, or HTML code, but it might
also be is hazardous...


Yes, that's possible.  See the manual, especially the section "2.12 
conditional text".


Duncan Murdoch

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] How to test package on Solaris

2011-11-03 Thread Dirk Eddelbuettel

On 3 November 2011 at 08:54, William Revelle wrote:
| Dear R developers,
| 
| Is there a way to pretest a package on the Solaris-sparc and solaris-x86 
systems equivalent to the win-builder check?

Nope, not as far as I know.  For Rcpp we are very much in the same boot. 
 
There was word of an upcoming 'bin-builder' similar to win-builder, but it
hasn't materialized.  You and I don't have a vote in that matter, but I think
this is a well definied task for which monies from the R Foundation would be
well spent.  Or a motivated company from the R universe could earn some
decent and recurrent karma points...

| My psych package (1.1.10 and 1.1.11) passes all checks for the Mac on my 
system, on the win-builder checking system supported by Uwe, and then passes 
Kurt's tests to install on CRAN.  But it then fails when being built for the 
solaris systems.  
| 
| Rather than burden Kurt and Uwe and the whole CRAN distribution process with 
frequent attempts to fix the problem, it would be preferable if I could pretest 
on a solaris system and then upload the final result.
| 
| I note from reading past queries to the list that this question has been 
asked before and the solution seems to have been some nice soul  volunteering 
to test a particular package.  A more general solution would seem preferred, if 
this is possible.

Correct. Matryn helped us recently with a patch for the solaris/x86 side of
things bringing the failure down to solaris/sparc only.  But our (ie Romain
and I) hands are tied as are yours. 

Cheers, Dirk

| Thanks.
| 
| Bill
| 
| 
| 
| William Revelle  
http://personality-project.org/revelle.html
| Professorhttp://personality-project.org
| Department of Psychology   http://www.wcas.northwestern.edu/psych/
| Northwestern University  http://www.northwestern.edu/
| Use R for psychology http://personality-project.org/r
| It is 6 minutes to midnight  http://www.thebulletin.org
| 
| __
| R-devel@r-project.org mailing list
| https://stat.ethz.ch/mailman/listinfo/r-devel

-- 
"Outside of a dog, a book is a man's best friend. Inside of a dog, it is too
dark to read." -- Groucho Marx

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] R CMD check and error in an \Sexpr in an Rd file

2011-11-03 Thread Georgi Boshnakov
Dear Renalud,, 

> Would a 'results=tex' (html, text) be possible? or 'results=source' that
> could be combined with \if{format}{text}?

This may well be a clean approach. 

After my previous email, I looked again at the definition of thr \AsIs macro. 
Its purpose seems to be to typeset text containing special characters in normal 
text mode 
and thus its purpose is different from \verb and ``verbatm'  
macros/environments in LaTeX.

Georgi

--
Dr Georgi Boshnakov   tel: (+44) (0)161 306 3684
School of Mathematics fax: (+44) (0)161 306 3669
Alan Turing Building 1.125
The University of Manchester  email: georgi.boshna...@manchester.ac.uk
Oxford Road
Manchester M13 9PL
UK



From: Renaud Gaujoux [ren...@cbio.uct.ac.za]
Sent: 03 November 2011 14:21
To: Georgi Boshnakov
Cc: Duncan Murdoch; Renaud Gaujoux; r-devel@r-project.org
Subject: Re: [Rd] R CMD check and error in an \Sexpr in an Rd file

Thank you Georgi.
With the fix \long the output is indeed consistent with the documentation.
I think my use of cat() worked by luck as its output should not have
been rendered.

Would a 'results=tex' (html, text) be possible? or 'results=source' that
could be combined with \if{format}{text}?
This would allow to generate custom Latex, or HTML code, but it might
also be is hazardous...

Renaud

--
Renaud Gaujoux
Computational Biology - University of Cape Town
South Africa


On 03/11/2011 15:50, Georgi Boshnakov wrote:
> Dear Duncan and Renauld,
>
>
> The error caused by the empty line(s) can be removed by prefixin the macro 
> with \long
> in Rd.sty:
>
> \long\def\Rd@AsIsX#1{\normalfont #1\egroup}
>
> but the slash-n's come up in the output.
>
> In "text mode" this seems not to be a problem. Following normal TeX rules one 
> needs to enter an empty line, e.g. by \n\n.
>
> Having written that, I tried putting two \n's in the verbatim text and it 
> seems to work (see below).
>
> I need to consult the TeX book to be sure but the
> problem with AsIs seems to be that by the time it starts processing its 
> argument it has been tokenized by TeX
> (hence single newlines have become spaces).
>
> Further thought may be needed about the new lines in verbatim.
> I may have missed again something but it seems that the observed output is 
> consistent with the
> documentation, which states:
>
>  "results=verbatim Print the results of the code just as if it was 
> executed at the
>  console, and include the printed results verbatim. (Invisible results 
> will not print.)"
>
> And the examples print on the console as they appear in output (with print, 
> not cat).
>
> Do we need exception from the general rule?
>
> An alternative would be to introduce results=verbatimLines option.
>
>
> Georgi
>
> \name{Sexpr}
> \alias{Sexpr}
> \title{Error and verbatim in Sexpr}
> \description{
>  Testing Sexpr in Rd files
>
>  %\Sexpr[results=verbatim, stage=render]{stop("error in sexpr")}
>
>  Verbatim:
>
>  1: \Sexpr[results=verbatim, stage=render]{cat("line\n\nnext line\n\n and 
> another")}
>
> %1a: \Sexpr[results=text, stage=render]{capture.output(cat(c("line", 
> "next line\n"),sep="\n", collapse="\n"))}
>
>  2: \Sexpr[results=verbatim, stage=render]{"line\nnext line\n"}
>
>  3: \Sexpr[results=verbatim, stage=render]{list("line\nnext line", 3)}
>
>  4: \Sexpr[results=verbatim, stage=render]{list(c("line", "next line"), 
> 3)}
>
>  Text:
>
>  1: \Sexpr[results=text, stage=render]{cat("line\nnext line\n")}
>
>  2: \Sexpr[results=text, stage=render]{"line\nnext line\n"}
>
>  3: \Sexpr[results=text, stage=render]{list("line\n\nnext  line 
> newline and another", 3)}
>
> }
>
>
>
> --
> Dr Georgi Boshnakov   tel: (+44) (0)161 306 3684
> School of Mathematics fax: (+44) (0)161 306 3669
> Alan Turing Building 1.125
> The University of Manchester  email: georgi.boshna...@manchester.ac.uk
> Oxford Road
> Manchester M13 9PL
> UK
>
>
> 
> From: Duncan Murdoch [murdoch.dun...@gmail.com]
> Sent: 03 November 2011 12:19
> To: Renaud Gaujoux
> Cc: Georgi Boshnakov; r-devel@r-project.org
> Subject: Re: [Rd] R CMD check and error in an \Sexpr in an Rd file
>
> On 11-11-03 7:58 AM, Renaud Gaujoux wrote:
>> Georgi, I tried with paste() instead of cat(), but I then get the
>> following in my PDF manual:
>>
>> [1] "line\nnext line"
>>
>> i.e. what would be printed in the R console, which is not what I want.
>> I would like to get something like this in the Latex code:
>>
>> \begin{verbatim}
>> line
>> next line
>> \end{verbatim}
> I don't think you want that:  it forces display mode.  You might want
> verbatim text displayed inline, like \verb does.
>
>> Using cat() I get the following in the Latex code:
>>
>> \AsIs{
>> line
>> next line}
>>
>> which does not render as a new line in the PDF and breaks if empty lines
>> are present in the output text.
> So the problem 

Re: [Rd] R CMD check and error in an \Sexpr in an Rd file

2011-11-03 Thread Renaud Gaujoux


On 03/11/2011 16:28, Duncan Murdoch wrote:

On 03/11/2011 10:21 AM, Renaud Gaujoux wrote:

Thank you Georgi.
With the fix \long the output is indeed consistent with the 
documentation.

I think my use of cat() worked by luck as its output should not have
been rendered.

Would a 'results=tex' (html, text) be possible? or 'results=source' that
could be combined with \if{format}{text}?
This would allow to generate custom Latex, or HTML code, but it might
also be is hazardous...


Yes, that's possible.  See the manual, especially the section "2.12 
conditional text".


Duncan Murdoch


Conditional text is possible, but latex or html code seem to be 
preprocessed and escaped, or maybe I am not doing the right things.


To test:


\name{Sexpr}
\alias{Sexpr}
\title{Error and verbatim in Sexpr}
\description{
Testing Sexpr in Rd files

\if{html}{\Sexpr[results=text, stage=render]{"text in 
bold"}}

\if{text}{\Sexpr[results=text, stage=render]{"_text in bold_"}}
\if{latex}{\Sexpr[results=text, stage=render]{"textbf{text in 
bold}"}}




}
%%%

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] R CMD check and error in an \Sexpr in an Rd file

2011-11-03 Thread Renaud Gaujoux


On 03/11/2011 16:33, Georgi Boshnakov wrote:

Dear Renalud,,


Would a 'results=tex' (html, text) be possible? or 'results=source' that
could be combined with \if{format}{text}?

This may well be a clean approach.

After my previous email, I looked again at the definition of thr \AsIs macro.
Its purpose seems to be to typeset text containing special characters in normal 
text mode
and thus its purpose is different from \verb and ``verbatm'  
macros/environments in LaTeX.

Maybe using an environment such as Verbatim defined in fancyvrb would 
solve the problem?
I think you can control the font, etc... still keeping the "no 
formatting" of plain verbatim.


__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] R CMD check and error in an \Sexpr in an Rd file

2011-11-03 Thread Duncan Murdoch

On 03/11/2011 10:49 AM, Renaud Gaujoux wrote:

On 03/11/2011 16:28, Duncan Murdoch wrote:
>  On 03/11/2011 10:21 AM, Renaud Gaujoux wrote:
>>  Thank you Georgi.
>>  With the fix \long the output is indeed consistent with the
>>  documentation.
>>  I think my use of cat() worked by luck as its output should not have
>>  been rendered.
>>
>>  Would a 'results=tex' (html, text) be possible? or 'results=source' that
>>  could be combined with \if{format}{text}?
>>  This would allow to generate custom Latex, or HTML code, but it might
>>  also be is hazardous...
>
>  Yes, that's possible.  See the manual, especially the section "2.12
>  conditional text".
>
>  Duncan Murdoch

Conditional text is possible, but latex or html code seem to be
preprocessed and escaped, or maybe I am not doing the right things.


Not if you ask it not to do that.  See the example in that section of 
the manual.


Duncan Murdoch


To test:


\name{Sexpr}
\alias{Sexpr}
\title{Error and verbatim in Sexpr}
\description{
  Testing Sexpr in Rd files

  \if{html}{\Sexpr[results=text, stage=render]{"text in
bold"}}
  \if{text}{\Sexpr[results=text, stage=render]{"_text in bold_"}}
  \if{latex}{\Sexpr[results=text, stage=render]{"textbf{text in
bold}"}}



}
%%%


__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] build 32-bit R on x86_64?

2011-11-03 Thread Vinh Nguyen
Hi everyone,

I was trying to reproduce building a 32 bit version of R on a 64 bit
Ubuntu 11.04 machine (which worked before) with the latest version of
R in SVN but am getting this error:

make[3]: Leaving directory `/home/vinh/Downloads/R/trunk/src/modules/lapack'
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libSM.so
when searching for -lSM
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libSM.a
when searching for -lSM
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libICE.so
when searching for -lICE
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libICE.a
when searching for -lICE
/usr/bin/ld: skipping incompatible
/usr/lib/x86_64-linux-gnu/libpangocairo-1.0.so when searching for
-lpangocairo-1.0
...


It should be looking in /usr/lib32, not /usr/lib.  I did the following
to arrive at these messages:

sudo apt-get install ia32-libs lib32readline6-dev lib32ncurses5-dev
lib32icu-dev gcc-multilib gfortran-multilib ## ubuntu does not have
ia32-libs-dev
./configure r_arch=i386 CC='gcc -std=gnu99 -m32' CXX='g++ -m32'
FC='gfortran -m32' F77='gfortran -m32'
make -j24

Any suggestions on how to fix this?  Thanks.

-- Vinh

On Wed, Aug 10, 2011 at 8:37 AM, Vinh Nguyen  wrote:
> On Tue, Aug 9, 2011 at 6:24 PM, Simon Urbanek
>  wrote:
>> It actually works ;) I'm using it for testing on my RForge.net machine and 
>> yes, it's Debian - everything just works there :).
>>
>> But back to the original question. First a minor detail, don't set 
>> environment variables use configure variables instead. Second, don't build 
>> in the source directory, always create an object directory. Third, r_arch is 
>> simply a name you set for the architecture, it has no meaning other than 
>> that it's a label.
>>
>> So now to the real stuff. If you want 32-bit build, you'll need 32-bit 
>> runtime of everything important in your system and the multilib compilers. 
>> In Debian (and thus likely in Ubuntu too) that can be achieved by something 
>> like
>>
>> sudo apt-get install  ia32-libs-dev lib32readline6-dev lib32ncurses5-dev 
>> lib32icu-dev gcc-multilib gfortran-multilib
>>
>> Then you can build both 64-bit and 32-bit R, the difference will be in the 
>> all compiler flags -- for 64-bit you'll use -m64 (or nothing since it's the 
>> default) and for 32-bit you'll use -m32.
>>
>> So roughly something like
>>
>> tar fxz R-2.13.1.tar.gz
>> mkdir obj-32
>> cd obj-32
>> ../R-2.13.1/configure r_arch=i386 CC='gcc -std=gnu99 -m32' CXX='g++ -m32' 
>> FC='gfortran -m32' F77='gfortran -m32'
>> make -j24 && sudo make install rhome=/usr/local/R/2.13
>> cd ..
>> mkdir obj-64
>> cd obj-64
>> ../R-2.13.1/configure r_arch=amd64
>> make -j24 && sudo make install rhome=/usr/local/R/2.13
>>
>> That will leave you with multi-arch R that you can run with
>> R --arch=i386 # 32-bit
>> R --arch=amd64 # 64-bit
>> Packages will be also built as multi-libs. Good luck :)
>> [BTW the rhome=... setting is entirely optional, I just like to keep my R 
>> versions organized…]
>>
>> Cheers,
>> Simon
>>
>
> Thanks Simon!  Confirm that these instructions work.  ia32-libs-dev
> was not available for Ubuntu Natty, so I installed ia32-libs instead,
> and the compilation works!
>
> -- Vinh

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] non-ascii vignettes

2011-11-03 Thread Hin-Tak Leung
Hi,

just saw "require vignettes to declare their encoding (trunk@57560)". Having 
played with non-ascii vignettes (well, a lot of Chinese...) on-and-off for 
almost two weeks, I noticed it was a bit odd that a *commented* 
\usepackage[utf8]{inputenc} had any effort at all on R's Sweave behavior - 
while it is understandable (probably no check is made whether a "%" is before 
\usepackage), it is probably wrong.

Besides commented statements having an effect, I found parsing \usepackage for 
encoding a bit disturbing - because at one point I was considering adding 
non-ascii's to one of the \usepackage options (hyperref can takes non-ascii for 
options), and it is possible, or may be even necessary, for \usepackage's to be 
in a particular order. There is also another drawback: if a latex document is 
multi-language, it is quite customary to have different encoding in different 
parts - one reason is to switch fonts and the availability of glyphs. 

FWIW, I noticed it because I was adding/removing \usepackage{}'s and switching 
between CJK and XeTeX a fair bit to see which gives me better results. They 
have different font selection mechanisms and different compatible/conflicted 
TeX packages; CJK on TexLive uses postscript Type 1 fonts while XeTeX uses 
Truetype/Opentype - the typeface is the same (both using a Arphic derivative) 
but the visual result is different.

HTH,
Hin-Tak


__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] [R] any updates w.r.t. lapply, sapply, apply retaining classes

2011-11-03 Thread Richard M. Heiberger
Mike,

On time classes specifically, the lubridate package
with documentation
Garrett Grolemund, Hadley Wickham (2011).
 Dates and Times Made Easy with lubridate.
 Journal of Statistical Software, 40(3), 1-25.
 http://www.jstatsoft.org/v40/i03/.

solves many confusion problems.  Does it handle the problems you are
reporting?

Rich



On Thu, Nov 3, 2011 at 7:49 PM, Mike Williamson wrote:

> Hi Joshua,
>
>Thank you for the input!
>
>I agree that it is non-trivial to solve the cases you & I have posed.
>  However, I would wholeheartedly support having an error spit back for any
> function that does not explicitly support a class.  In this case, if I
> attempt to do   sapply(x, class), and 'x' is of class "difftime", then I
> should receive an error "sapply cannot function upon class 'difftime' ".
>  Why do I take this stance?  There are at least 2 strong reasons:
>
>   - Most importantly, an incorrect answer is far more dangerous than no
>   answer.  E.g., if I ask "what is 3 + 3?", I would far prefer to receive
> "I
>   don't know" than "5".  The former lets me know I need to choose another
>   path, the latter mistakenly makes me think I have an answer, when I do
> not,
>   and I continue with analyses on the assumption that answer is correct.
>  In
>   the case of dates, this happens often.  E.g., is the numeric that is
>   returned from sapply, for instance, the # of seconds since 1970-01-01, or
>   the number of days since 1970-01-01.  This depends upon how 'R'
> internally
>   attempts to fix any incongruities.
>   - But also very significantly, an error will get me in the habit of
>   avoiding any marginalized class types.  I keep thinking, for instance,
> that
>   I can use the "Dates" class, since 'R' says that it supports them.  But
> if
>   I got into the habit of converting all dates into numerics myself
>   beforehand (maybe counting the number of seconds from 1970-01-01, since
>   that seems a magic date), then I would be guaranteed that a function will
>   either (a) cause an error (e.g., if I try a character function on it), or
>   (b) function properly.  However, since I don't overtly receive errors
> when
>   attempting to use dates (or difftimes, or factors, or whatever), I keep
>   using them, instead of relying solely upon the true & trusted classes.
>  - the trickiest here is really factors.  Factors are, by most
>  accounts, considered a core class.  In some cases, you can only use
>  factors.  E.g., when you want some sort of ordinal categorical
> variable.
>   Therefore, the fact that factors also barf similarly to other
> classes like
>  difftime (albeit much more rarely), is especially dangerous.
>
>There are, of course, habits that we can create to make ourselves
> better programmers, and I will recognize that I can improve.  However, this
> issue of functions generating "wrong" answers is such a *huge* problem with
> 'R', and other languages are catching up to 'R' so quickly, as far as their
> capability to handle higher level math, that this issue is making 'R' a
> less desirable language to use, as time progresses.  I don't mean to claim
> that my opinion is the end-all-be-all, but I would like to hear others
> chime in, whether this is a large concern, or whether there is a very small
> minority of folks impacted by it.
>
>  Regards,
> Mike
>
> ---
> XKCD 
>
>
>
> On Thu, Nov 3, 2011 at 2:51 PM, Joshua Wiley 
> wrote:
>
> > Hi Mike,
> >
> > This isn't really an answer to your question, but perhaps will serve
> > to continue discussion.  I think that there are some fundamental
> > issues when working special classes.  As a thought example, suppose I
> > wrote a class, "posreal", which inherits from the numeric class.  It
> > is only valid for positive, real numbers.  I use it in a package, but
> > do not develop methods for it.  A user comes along and creates a
> > vector, x that is a posreal.  Then tries: mean(x * -3).  Since I never
> > bothered to write a special method for mean for my class, R falls back
> > to the inherited numeric, but gives a value that is clearly not valid
> > for posreal.  What should happen?  S3 methods do not really have
> > validation, so in principle, one could write a function like:
> >
> > f <- function(x) {
> >  vclass <- class(x)
> >  res <- mean(x)
> >  class(res) <- vclass
> >  return(res)
> > }
> >
> > which "retains" the appropriate class, but in name only.  R core
> > cannot possibly know or imagine all classes that may be written that
> > inherit from more basic types but with possible special aspects and
> > requirements.  I think the inherited is considered to be more generic
> > and that is returned.  It is usually up to the user to ensure that the
> > function (whose methods were not specific to that special class but
> > the inherited) is valid for that class and can manually con

Re: [Rd] [R] any updates w.r.t. lapply, sapply, apply retaining classes

2011-11-03 Thread Hadley Wickham
>    I agree that it is non-trivial to solve the cases you & I have posed.
>  However, I would wholeheartedly support having an error spit back for any
> function that does not explicitly support a class.  In this case, if I
> attempt to do   sapply(x, class), and 'x' is of class "difftime", then I
> should receive an error "sapply cannot function upon class 'difftime' ".
>  Why do I take this stance?  There are at least 2 strong reasons:

I don't see why that command should be a problem because class()
returns a string.

A better example might be sapply(x, identity) which in general you
would hope to be identical to x:

x <- structure(1:10, class = "blah")
identical(x, sapply(x, identity))
# [1] FALSE

Hadley

-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Call function only when running via R CMD check?

2011-11-03 Thread Henrik Bengtsson
On Wed, Nov 2, 2011 at 7:40 PM, Henrik Bengtsson  wrote:
> I'd like to be able to change some default settings only in the case
> when checking a package with 'R CMD check'.  More precisely, I'd like
> to execute a piece of R code before the Rd examples and/or test
> scripts are evaluated by 'R CMD check'.  Is there a mechanism in 'R
> CMD check' that makes this possible?  If not, is there a way to detect
> that you are running via 'R CMD check', e.g. an R or an environment
> variable being set?
>
> The background for this is that some of my packages' examples are
> using memoization to cache computational expensive results (via the
> 'R.cache' package).  These are cached to files which are by default
> stored under ~/.Rcache/.   It turns out that these files live beyond
> the check cycle of the CRAN check servers, meaning that the next time
> the package is checked memoized results will be picked up.  If I could
> detect that we're running via 'R CMD check', then I could change the
> default cache directory to a temporary directory (e.g. tempdir()) that
> will be clean out automatically.
>
> This is not a critical problem, because for now I could explicitly
> turn off the memoization in the code of my examples/regression tests,
> but the above would be a more generic solution.

I've got a few off-line suggestions (thanks).  It seems that there is
no certain way of doing this, but one can look for various evidences
available in the current R session, such as looking at the content of
commandArgs(), search() and getwd().  Trying to infer whether 'R CMD
check' runs and if it checks examples or tests based on this won't be
100% safe, but probably good enough.  Best would be if 'R CMD check'
would pass a environment variable (or a command argument) to the R
session reporting on its state (that's a wish), e.g.

R R_CMD_CHECK_STATE="checkingExamples" LANGUAGE=en --vanilla -f MyPackage-Ex.R
R R_CMD_CHECK_STATE="checkingTest" -f myTest.R --restore --save --vanilla

/Henrik

>
> Thanks
>
> Henrik
>

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] [R] any updates w.r.t. lapply, sapply, apply retaining classes

2011-11-03 Thread Mike Williamson
Hi Joshua,

Thank you for the input!

I agree that it is non-trivial to solve the cases you & I have posed.
 However, I would wholeheartedly support having an error spit back for any
function that does not explicitly support a class.  In this case, if I
attempt to do   sapply(x, class), and 'x' is of class "difftime", then I
should receive an error "sapply cannot function upon class 'difftime' ".
 Why do I take this stance?  There are at least 2 strong reasons:

   - Most importantly, an incorrect answer is far more dangerous than no
   answer.  E.g., if I ask "what is 3 + 3?", I would far prefer to receive "I
   don't know" than "5".  The former lets me know I need to choose another
   path, the latter mistakenly makes me think I have an answer, when I do not,
   and I continue with analyses on the assumption that answer is correct.  In
   the case of dates, this happens often.  E.g., is the numeric that is
   returned from sapply, for instance, the # of seconds since 1970-01-01, or
   the number of days since 1970-01-01.  This depends upon how 'R' internally
   attempts to fix any incongruities.
   - But also very significantly, an error will get me in the habit of
   avoiding any marginalized class types.  I keep thinking, for instance, that
   I can use the "Dates" class, since 'R' says that it supports them.  But if
   I got into the habit of converting all dates into numerics myself
   beforehand (maybe counting the number of seconds from 1970-01-01, since
   that seems a magic date), then I would be guaranteed that a function will
   either (a) cause an error (e.g., if I try a character function on it), or
   (b) function properly.  However, since I don't overtly receive errors when
   attempting to use dates (or difftimes, or factors, or whatever), I keep
   using them, instead of relying solely upon the true & trusted classes.
  - the trickiest here is really factors.  Factors are, by most
  accounts, considered a core class.  In some cases, you can only use
  factors.  E.g., when you want some sort of ordinal categorical variable.
   Therefore, the fact that factors also barf similarly to other
classes like
  difftime (albeit much more rarely), is especially dangerous.

There are, of course, habits that we can create to make ourselves
better programmers, and I will recognize that I can improve.  However, this
issue of functions generating "wrong" answers is such a *huge* problem with
'R', and other languages are catching up to 'R' so quickly, as far as their
capability to handle higher level math, that this issue is making 'R' a
less desirable language to use, as time progresses.  I don't mean to claim
that my opinion is the end-all-be-all, but I would like to hear others
chime in, whether this is a large concern, or whether there is a very small
minority of folks impacted by it.

  Regards,
 Mike

---
XKCD 



On Thu, Nov 3, 2011 at 2:51 PM, Joshua Wiley  wrote:

> Hi Mike,
>
> This isn't really an answer to your question, but perhaps will serve
> to continue discussion.  I think that there are some fundamental
> issues when working special classes.  As a thought example, suppose I
> wrote a class, "posreal", which inherits from the numeric class.  It
> is only valid for positive, real numbers.  I use it in a package, but
> do not develop methods for it.  A user comes along and creates a
> vector, x that is a posreal.  Then tries: mean(x * -3).  Since I never
> bothered to write a special method for mean for my class, R falls back
> to the inherited numeric, but gives a value that is clearly not valid
> for posreal.  What should happen?  S3 methods do not really have
> validation, so in principle, one could write a function like:
>
> f <- function(x) {
>  vclass <- class(x)
>  res <- mean(x)
>  class(res) <- vclass
>  return(res)
> }
>
> which "retains" the appropriate class, but in name only.  R core
> cannot possibly know or imagine all classes that may be written that
> inherit from more basic types but with possible special aspects and
> requirements.  I think the inherited is considered to be more generic
> and that is returned.  It is usually up to the user to ensure that the
> function (whose methods were not specific to that special class but
> the inherited) is valid for that class and can manually convert it
> back:
>
> res <- as.posreal(res)
>
> What about lapply and sapply?  Neither are generic or have methods for
> difftime, and so do some unexpected/desirable things.  Again, without
> methods defined for a particular class, they cannot know what is
> special or appropriate way to handle it, they use defaults which
> sometimes work but may give unexpected or undesirable results, but
> what else can be done?  (okay, they could just throw an error)  If a
> function is naive about a class, it does not seem right to operate on
> it