[Rd] accented charatchers in a package manual

2012-11-14 Thread Denis Talbot
Dear list,

I am writing an R package manual and there is still a warning when I run "R
CMD check" about "NON-ASCII contents without declared encoding". I do get
the warning comes from an accent in the name of one of the author
(Geneviève), but I can't find what I am supposed to do about it. I know
there is a section about encoding in the "Writing R extension" manual, but
I couldn't understand what I should do from reading it.

Any help is welcomed.

Denis Talbot

[[alternative HTML version deleted]]

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


Re: [Rd] accented charatchers in a package manual

2012-11-14 Thread Duncan Murdoch

On 14/11/2012 9:22 AM, Denis Talbot wrote:

Dear list,

I am writing an R package manual and there is still a warning when I run "R
CMD check" about "NON-ASCII contents without declared encoding". I do get
the warning comes from an accent in the name of one of the author
(Geneviève), but I can't find what I am supposed to do about it. I know
there is a section about encoding in the "Writing R extension" manual, but
I couldn't understand what I should do from reading it.

Any help is welcomed.



You need to declare what encoding you are using.  Put a line in your 
DESCRIPTION file like


Encoding:  utf-8

If you don't know what encoding you are using, you can probably find out 
by reading the docs for your text editor, or just guess:  If you are on 
Windows it is likely latin1, on Linux it is likely utf-8.  If you guess 
wrong you'll get errors or ugly text when R produces the manual.


Duncan Murdoch

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


Re: [Rd] accented charatchers in a package manual

2012-11-14 Thread Prof Brian Ripley

On 14/11/2012 15:24, Duncan Murdoch wrote:

On 14/11/2012 9:22 AM, Denis Talbot wrote:

Dear list,

I am writing an R package manual and there is still a warning when I
run "R
CMD check" about "NON-ASCII contents without declared encoding". I do get
the warning comes from an accent in the name of one of the author
(Geneviève), but I can't find what I am supposed to do about it. I know
there is a section about encoding in the "Writing R extension" manual,
but
I couldn't understand what I should do from reading it.

Any help is welcomed.



You need to declare what encoding you are using.  Put a line in your
DESCRIPTION file like

Encoding:  utf-8

If you don't know what encoding you are using, you can probably find out
by reading the docs for your text editor, or just guess:  If you are on
Windows it is likely latin1, on Linux it is likely utf-8.  If you guess
wrong you'll get errors or ugly text when R produces the manual.


But note the manual says

'Only encoding names latin1, latin2 and UTF-8 are known to be portable.'

'utf-8' is never correct and may or may not be accepted.

The error message 'Non-ASCII contents without declared encoding' (sic) 
occurs in processing Rd files.  So you would probably do better to add a 
\encoding{} line to the Rd file where the name occurs.  There are many 
examples in the R sources, e.g. src/library/graphics/man/text.Rd .




Duncan Murdoch

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



--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

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


[Rd] Typo in documentation for reshape?

2012-11-14 Thread Michael Dewey

When I go ?reshape I get told, amongst other things

new.row.names
logical; if TRUE and direction = "wide", create new row names in long 
format from the values of the id and time variables.


This seems to me to be illogical, surely it should read direction = "long"?

Reading the code and observing its behaviour I find that (a) the 
default for new.row.names is in fact NULL (b) the default seems to 
give the behaviour described above for TRUE (c) it is tested in the 
code only as if(is.null(new.row.names)) or if(!is.null(new.row.names))


Note I am not complaining about the behaviour, it does what I would 
want and what seems to me to be the natural thing but I do not think 
it is quite as documented.


R version 2.15.2 (2012-10-26)
Platform: i386-w64-mingw32/i386 (32-bit)



Michael Dewey
i...@aghmed.fsnet.co.uk
http://www.aghmed.fsnet.co.uk/home.html

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


Re: [Rd] Typo in documentation for reshape?

2012-11-14 Thread peter dalgaard

On Nov 14, 2012, at 19:15 , Michael Dewey wrote:

> When I go ?reshape I get told, amongst other things
> 
> new.row.names
> logical; if TRUE and direction = "wide", create new row names in long format 
> from the values of the id and time variables.
> 
> This seems to me to be illogical, surely it should read direction = "long"?
> 
> Reading the code and observing its behaviour I find that (a) the default for 
> new.row.names is in fact NULL (b) the default seems to give the behaviour 
> described above for TRUE (c) it is tested in the code only as 
> if(is.null(new.row.names)) or if(!is.null(new.row.names))
> 
> Note I am not complaining about the behaviour, it does what I would want and 
> what seems to me to be the natural thing but I do not think it is quite as 
> documented.
> 

I believe this, and a bit more, is in bug #15102. 

The report hasn't been acted upon, but not been dismissed either, so presumably 
there's general agreement that something is wrong, but someone needs to check 
the suggested fixups in detail.

It's quite amusing how issues can go unnoticed for years and then be reported 
by two different people within a week. Or is there perhaps a more direct reason 
that the two of you should happen to be on the same page?

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@gmail.com

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


Re: [Rd] Typo in documentation for reshape?

2012-11-14 Thread Michael Dewey

At 19:10 14/11/2012, peter dalgaard wrote:


On Nov 14, 2012, at 19:15 , Michael Dewey wrote:

> When I go ?reshape I get told, amongst other things
>
> new.row.names
> logical; if TRUE and direction = "wide", create new row names in 
long format from the values of the id and time variables.

>
> This seems to me to be illogical, surely it should read direction = "long"?
>
> Reading the code and observing its behaviour I find that (a) the 
default for new.row.names is in fact NULL (b) the default seems to 
give the behaviour described above for TRUE (c) it is tested in the 
code only as if(is.null(new.row.names)) or if(!is.null(new.row.names))

>
> Note I am not complaining about the behaviour, it does what I 
would want and what seems to me to be the natural thing but I do 
not think it is quite as documented.

>

I believe this, and a bit more, is in bug #15102.

The report hasn't been acted upon, but not been dismissed either, so 
presumably there's general agreement that something is wrong, but 
someone needs to check the suggested fixups in detail.


It's quite amusing how issues can go unnoticed for years and then be 
reported by two different people within a week. Or is there perhaps 
a more direct reason that the two of you should happen to be on the same page?


I am not sure how to find who authored the bug report but I have not 
used reshape for a while and I found the documentation issue this 
afternoon and so must assume this is just a coincidence. As I implied 
originally I do not think it is a bug, more of an undocumented feature.




--
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@gmail.com


Michael Dewey
i...@aghmed.fsnet.co.uk
http://www.aghmed.fsnet.co.uk/home.html

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


[Rd] bug with mapply() on an S4 object

2012-11-14 Thread Hervé Pagès

Hi,

Starting with ordinary vectors, so we know what to expect:

  > mapply(function(x, y) {x * y}, 101:106, rep(1:3, 2))
  [1] 101 204 309 104 210 318

  > mapply(function(x, y) {x * y}, 101:106, 1:3)
  [1] 101 204 309 104 210 318

Now with an S4 object:

  setClass("A", representation(aa="integer"))
  a <- new("A", aa=101:106)

  > length(a)
  [1] 1

Implementing length():

  setMethod("length", "A", function(x) length(x@aa))

Testing length():

  > length(a)  # sanity check
  [1] 6

No [[ yet for those objects so the following error is expected:

  > mapply(function(x, y) {x * y}, a, rep(1:3, 2))
  Error in dots[[1L]][[1L]] : this S4 class is not subsettable

Implementing [[:

  setMethod("[[", "A", function(x, i, j, ...) x@aa[[i]])

Testing [[:

  > a[[1]]
  [1] 101
  > a[[5]]
  [1] 105

Trying mapply again:

  > mapply(function(x, y) {x * y}, a, rep(1:3, 2))
  [1] 101 202 303 101 202 303

Wrong. It looks like internally a[[1]] is always used instead of a[[i]].

The real problem it seems is that 'a' is treated as if it was of
length 1:

  > mapply(function(x, y) {x * y}, a, 1:3)
  [1] 101 202 303
  > mapply(function(x, y) {x * y}, a, 5)
  [1] 505

In other words, internal dispatch works for [[ but not for length().

Thanks,
H.

--
Hervé Pagès

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: hpa...@fhcrc.org
Phone:  (206) 667-5791
Fax:(206) 667-1319

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