Re: [Rd] html help fails for named vector objects (PR#9927)

2007-09-23 Thread Peter Dalgaard
[EMAIL PROTECTED] wrote:
help(letters, htmlhelp=TRUE) fails.

 Under the Mac OSX gui, the message is 'Help for the topic a was not  
 found.' Under the version documented below, and under Windows, the  
 message is

No documentation for 'a' in specified packages and libraries:
 repeated for all the elements of letters, then followed by
you could try 'help.search(a)',
 again repeated for all elements of letters.

 The outcome seems similar for any character vector (including matrix)  
 object, e.g. the matrix 'primateDNA' in the DAAGbio package.

 The following have the expected result
help(letters, htmlhelp=TRUE)
help(letters, htmlhelp=FALSE)

   
Not for me. I get the same thing with or without htmlhelp. (That IS what 
I expected, though)

The logic in help is

ischar - try(is.character(topic), silent = TRUE)
if (inherits(ischar, try-error))
ischar - FALSE
if (!ischar)
topic - deparse(substitute(topic))

So a character argument implies that it contains the names of help 
topics. That isn't quite what the documentation says, though:

   topic: usually, the name on which documentation is sought. The name
  may be quoted or unquoted (but note that if 'topic' is the
  name of a variable containing a character string
  documentation is provided for the name, not for the character
  string).

It is the documentation that is wrong. We could implement what it says, 
but then it would be a require considerable contortions to get help on a 
topic stored in a variable (e.g., coming from a help field in a GUI).

It isn't clear to me that  it should try all elements of a character 
vector of length  1. That looks like a bit of a booby trap to me -- 
what if it accidentally caught a variable with a few million elements? A 
length check should be rather easy.


 The same result is obtained with R-2.5.1.


 --please do not edit the information below--

 Version:
 platform = i386-apple-darwin8.10.1
 arch = i386
 os = darwin8.10.1
 system = i386, darwin8.10.1
 status = beta
 major = 2
 minor = 6.0
 year = 2007
 month = 09
 day = 22
 svn rev = 42941
 language = R
 version.string = R version 2.6.0 beta (2007-09-22 r42941)

 Locale:
 C

 Search Path:
 .GlobalEnv, package:testpkg, package:stats, package:graphics,  
 package:grDevices, package:utils, package:datasets, package:methods,  
 Autoloads, package:base

 John Maindonald email: [EMAIL PROTECTED]
 phone : +61 2 (6125)3473fax  : +61 2(6125)5549
 Centre for Mathematics  Its Applications, Room 1194,
 John Dedman Mathematical Sciences Building (Building 27)
 Australian National University, Canberra ACT 0200.

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


-- 
   O__   Peter Dalgaard Ă˜ster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

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


Re: [Rd] html help fails for named vector objects (PR#9927)

2007-09-23 Thread ripley
On a normal R help system any version of help(letters) tries to give you 
help on a, b, etc.  This is intentional (although the documentation is 
unclearly worded), and has been the case since at least R 2.0.0.
Some versions of help will display only the first topic.

If help(letters, htmlhelp=FALSE) does something else on your system, that 
is a MacOS-specific bug since the topic selected should not depend on the 
optional arguments.

What is unclear from the documentation is what should happen with

help(c(help, help.search))

It seems that for text help you get the first, for htmlhelp both.

There are two things we could do to help (apart from clarifying the 
documentation):

1) If 'topic' is neither a name nor a character vector (e.g. an expression 
like the last example) give an explicit error.

2) if topic is a character vector of length  1, use the name.


On Sun, 23 Sep 2007, [EMAIL PROTECTED] wrote:

   help(letters, htmlhelp=TRUE) fails.

 Under the Mac OSX gui, the message is 'Help for the topic a was not
 found.' Under the version documented below, and under Windows, the
 message is

   No documentation for 'a' in specified packages and libraries:
 repeated for all the elements of letters, then followed by
   you could try 'help.search(a)',
 again repeated for all elements of letters.

 The outcome seems similar for any character vector (including matrix)
 object, e.g. the matrix 'primateDNA' in the DAAGbio package.

 The following have the expected result
   help(letters, htmlhelp=TRUE)
   help(letters, htmlhelp=FALSE)

But the documented and actual results are the same, and different in the 
two cases.

 The same result is obtained with R-2.5.1.


 --please do not edit the information below--

 Version:
 platform = i386-apple-darwin8.10.1
 arch = i386
 os = darwin8.10.1
 system = i386, darwin8.10.1
 status = beta
 major = 2
 minor = 6.0
 year = 2007
 month = 09
 day = 22
 svn rev = 42941
 language = R
 version.string = R version 2.6.0 beta (2007-09-22 r42941)

 Locale:
 C

 Search Path:
 .GlobalEnv, package:testpkg, package:stats, package:graphics,
 package:grDevices, package:utils, package:datasets, package:methods,
 Autoloads, package:base

 John Maindonald email: [EMAIL PROTECTED]
 phone : +61 2 (6125)3473fax  : +61 2(6125)5549
 Centre for Mathematics  Its Applications, Room 1194,
 John Dedman Mathematical Sciences Building (Building 27)
 Australian National University, Canberra ACT 0200.

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


-- 
Brian D. Ripley,  [EMAIL PROTECTED]
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


Re: [Rd] html help fails for named vector objects (PR#9927)

2007-09-23 Thread Prof Brian Ripley
On a normal R help system any version of help(letters) tries to give you 
help on a, b, etc.  This is intentional (although the documentation is 
unclearly worded), and has been the case since at least R 2.0.0.
Some versions of help will display only the first topic.

If help(letters, htmlhelp=FALSE) does something else on your system, that 
is a MacOS-specific bug since the topic selected should not depend on the 
optional arguments.

What is unclear from the documentation is what should happen with

help(c(help, help.search))

It seems that for text help you get the first, for htmlhelp both.

There are two things we could do to help (apart from clarifying the 
documentation):

1) If 'topic' is neither a name nor a character vector (e.g. an expression 
like the last example) give an explicit error.

2) if topic is a character vector of length  1, use the name.


On Sun, 23 Sep 2007, [EMAIL PROTECTED] wrote:

   help(letters, htmlhelp=TRUE) fails.

 Under the Mac OSX gui, the message is 'Help for the topic a was not
 found.' Under the version documented below, and under Windows, the
 message is

   No documentation for 'a' in specified packages and libraries:
 repeated for all the elements of letters, then followed by
   you could try 'help.search(a)',
 again repeated for all elements of letters.

 The outcome seems similar for any character vector (including matrix)
 object, e.g. the matrix 'primateDNA' in the DAAGbio package.

 The following have the expected result
   help(letters, htmlhelp=TRUE)
   help(letters, htmlhelp=FALSE)

But the documented and actual results are the same, and different in the 
two cases.

 The same result is obtained with R-2.5.1.


 --please do not edit the information below--

 Version:
 platform = i386-apple-darwin8.10.1
 arch = i386
 os = darwin8.10.1
 system = i386, darwin8.10.1
 status = beta
 major = 2
 minor = 6.0
 year = 2007
 month = 09
 day = 22
 svn rev = 42941
 language = R
 version.string = R version 2.6.0 beta (2007-09-22 r42941)

 Locale:
 C

 Search Path:
 .GlobalEnv, package:testpkg, package:stats, package:graphics,
 package:grDevices, package:utils, package:datasets, package:methods,
 Autoloads, package:base

 John Maindonald email: [EMAIL PROTECTED]
 phone : +61 2 (6125)3473fax  : +61 2(6125)5549
 Centre for Mathematics  Its Applications, Room 1194,
 John Dedman Mathematical Sciences Building (Building 27)
 Australian National University, Canberra ACT 0200.

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


-- 
Brian D. Ripley,  [EMAIL PROTECTED]
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


Re: [Rd] html help fails for named vector objects (PR#9927)

2007-09-23 Thread P Ehlers
There seems also to be a difference between the way 'help()' and '?'
handle 'topic' in some cases.

Consider:
lm - aov

The following all bring up help for 'lm':
?lm
?lm
help(lm)

This opens help for 'aov':
help(lm)

It seems that ? doesn't care about quoting, but help does.
Did I miss something in the docs?
(If it matters, I'm using options(chmhelp=TRUE).)

  sessionInfo()
R version 2.6.0 beta (2007-09-18 r42895)
i386-pc-mingw32

locale:
LC_COLLATE=English_Canada.1252; [snip]

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base

  - Peter Ehlers

Prof Brian Ripley wrote:
 On a normal R help system any version of help(letters) tries to give you 
 help on a, b, etc.  This is intentional (although the documentation is 
 unclearly worded), and has been the case since at least R 2.0.0.
 Some versions of help will display only the first topic.
 
 If help(letters, htmlhelp=FALSE) does something else on your system, that 
 is a MacOS-specific bug since the topic selected should not depend on the 
 optional arguments.
 
 What is unclear from the documentation is what should happen with
 
 help(c(help, help.search))
 
 It seems that for text help you get the first, for htmlhelp both.
 
 There are two things we could do to help (apart from clarifying the 
 documentation):
 
 1) If 'topic' is neither a name nor a character vector (e.g. an expression 
 like the last example) give an explicit error.
 
 2) if topic is a character vector of length  1, use the name.
 
 
 On Sun, 23 Sep 2007, [EMAIL PROTECTED] wrote:
 
   help(letters, htmlhelp=TRUE) fails.

 Under the Mac OSX gui, the message is 'Help for the topic a was not
 found.' Under the version documented below, and under Windows, the
 message is

   No documentation for 'a' in specified packages and libraries:
 repeated for all the elements of letters, then followed by
   you could try 'help.search(a)',
 again repeated for all elements of letters.

 The outcome seems similar for any character vector (including matrix)
 object, e.g. the matrix 'primateDNA' in the DAAGbio package.

 The following have the expected result
   help(letters, htmlhelp=TRUE)
   help(letters, htmlhelp=FALSE)
 
 But the documented and actual results are the same, and different in the 
 two cases.
 
 The same result is obtained with R-2.5.1.


 --please do not edit the information below--

 Version:
 platform = i386-apple-darwin8.10.1
 arch = i386
 os = darwin8.10.1
 system = i386, darwin8.10.1
 status = beta
 major = 2
 minor = 6.0
 year = 2007
 month = 09
 day = 22
 svn rev = 42941
 language = R
 version.string = R version 2.6.0 beta (2007-09-22 r42941)

 Locale:
 C

 Search Path:
 .GlobalEnv, package:testpkg, package:stats, package:graphics,
 package:grDevices, package:utils, package:datasets, package:methods,
 Autoloads, package:base

 John Maindonald email: [EMAIL PROTECTED]
 phone : +61 2 (6125)3473fax  : +61 2(6125)5549
 Centre for Mathematics  Its Applications, Room 1194,
 John Dedman Mathematical Sciences Building (Building 27)
 Australian National University, Canberra ACT 0200.

 __
 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] initial scrambling of seed in do_setseed / RNG_Init

2007-09-23 Thread Petr Savicky
I would like to suggest a modification of initial scrambling of the
seed in RNG_Init (called from do_setseed). The modified code is
equivalent, but faster. Patch against R-devel_2007-09-22 follows

--- R-devel-orig/src/main/RNG.c 2007-09-02 07:49:35.0 +0200
+++ R-devel-modif/src/main/RNG.c2007-09-23 10:51:59.234566440 +0200
@@ -216,8 +216,8 @@
 BM_norm_keep = 0.0; /* zap Box-Muller history */
 
 /* Initial scrambling */
-for(j = 0; j  50; j++)
-   seed = (69069 * seed + 1);
+/* Equivalent to 50 iterations of seed = (69069 * seed + 1) */
+seed = (1100682473U * seed + 2358491998U);
 switch(kind) {
 case WICHMANN_HILL:
 case MARSAGLIA_MULTICARRY:

Let me add also the following remark. The help(Random.user) page says

 Optionally, the user can supply the entry point 'user_unif_init',
 which is called with an 'unsigned int' argument when 'RNGkind' (or
 'set.seed') is called, and is intended to be used to initialize
 the user's RNG code. The argument is intended to be used to set
 the seeds; it is the 'seed' argument to 'set.seed' or an
 essentially random seed if 'RNGkind' is called.

I want to comment on the sentence
   The argument is intended to be used to set
   the seeds; it is the 'seed' argument to 'set.seed' or 
This is not correct. If user_unif_init is called from set.seed, then
it receives the argument of set.seed after the initial scrambling.
If someone writes a user defined generator and wishes to get the original
seed specified in set.seed (which is my situation), then it may be useful
for him to know that the transformation 
  seed = 3602842457U * (seed - 2358491998U);
is the inverse to the initial scrambling. Hence, if it is applied to the
value received by user_unif_init, it provides the original value specified
by the user in set.seed.

Let me point out that the initial scrambling does not eliminate seed 0.
It only decreases the probability that this seed is sent to the generator.
Due to scrambling, the entry point user_unif_init receives 0 not as a
consequence of set.seed(0), but as a consequence of set.seed(105890386).
This is less likely, but still possible.

I suggest to clarify the page help(Random.user) concerning the transformation
of the seed. For example, the sentence
  it is the 'seed' argument to 'set.seed'
may be extended to
  it is the 'seed' argument to 'set.seed' after a transformation described
  in function RNG_Init in src/main/RNG.c

Also, a remark concerning the inverse transformation may be add. In my opinion,
the best way to do this could be to add a comment to RNG_Init in src/main/RNG.c,
saying, for example:
  If you need to undo the initial scrambling in user_unif_init, use
  seed = 3602842457U * (seed - 2358491998U);

Petr Savicky.

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


Re: [Rd] html help fails for named vector objects (PR#9927)

2007-09-23 Thread Prof Brian Ripley
On Sun, 23 Sep 2007, P Ehlers wrote:

 There seems also to be a difference between the way 'help()' and '?'
 handle 'topic' in some cases.

Yes, that is intentional.  I didn't mention it (after deliberation) as the 
bug report was about help(htmlhelp=TRUE) and not ?.  I did mention 
clarifying the documentation, which in my draft says

topic: usually, a name or character string specifying the topic for
   which help is sought.

   For 'help', if 'topic' is a length-one character vector, the
   topic is taken to be the value of the only element.

   For '?' the 'topic' argument may also be a function call, to
   ask for documentation on a corresponding method.  See the
   section on S4 method documentation.

but I am still tweaking.

 Consider:
 lm - aov

 The following all bring up help for 'lm':
 ?lm
 ?lm
 help(lm)

 This opens help for 'aov':
 help(lm)

 It seems that ? doesn't care about quoting, but help does.
 Did I miss something in the docs?

No, as it is not in the docs as yet.  The help page described what happens 
for ?, not for help, e.g.

   The 'topic' argument may also be a function call, to ask for
   documentation on a corresponding method.  See the section on
   method documentation.

applies only to ? .

 (If it matters, I'm using options(chmhelp=TRUE).)

It will not if utils::help is being called.


 sessionInfo()
 R version 2.6.0 beta (2007-09-18 r42895)
 i386-pc-mingw32

 locale:
 LC_COLLATE=English_Canada.1252; [snip]

 attached base packages:
 [1] stats graphics  grDevices utils datasets  methods   base

 - Peter Ehlers

 Prof Brian Ripley wrote:
 On a normal R help system any version of help(letters) tries to give you 
 help on a, b, etc.  This is intentional (although the documentation is 
 unclearly worded), and has been the case since at least R 2.0.0.
 Some versions of help will display only the first topic.
 
 If help(letters, htmlhelp=FALSE) does something else on your system, that 
 is a MacOS-specific bug since the topic selected should not depend on the 
 optional arguments.
 
 What is unclear from the documentation is what should happen with
 
 help(c(help, help.search))
 
 It seems that for text help you get the first, for htmlhelp both.
 
 There are two things we could do to help (apart from clarifying the 
 documentation):
 
 1) If 'topic' is neither a name nor a character vector (e.g. an expression 
 like the last example) give an explicit error.
 
 2) if topic is a character vector of length  1, use the name.
 
 
 On Sun, 23 Sep 2007, [EMAIL PROTECTED] wrote:

   help(letters, htmlhelp=TRUE) fails.
 
 Under the Mac OSX gui, the message is 'Help for the topic a was not
 found.' Under the version documented below, and under Windows, the
 message is

   No documentation for 'a' in specified packages and libraries:
 repeated for all the elements of letters, then followed by
   you could try 'help.search(a)',
 again repeated for all elements of letters.
 
 The outcome seems similar for any character vector (including matrix)
 object, e.g. the matrix 'primateDNA' in the DAAGbio package.
 
 The following have the expected result
   help(letters, htmlhelp=TRUE)
   help(letters, htmlhelp=FALSE)
 
 But the documented and actual results are the same, and different in the 
 two cases.
 
 The same result is obtained with R-2.5.1.
 
 
 --please do not edit the information below--
 
 Version:
 platform = i386-apple-darwin8.10.1
 arch = i386
 os = darwin8.10.1
 system = i386, darwin8.10.1
 status = beta
 major = 2
 minor = 6.0
 year = 2007
 month = 09
 day = 22
 svn rev = 42941
 language = R
 version.string = R version 2.6.0 beta (2007-09-22 r42941)
 
 Locale:
 C
 
 Search Path:
 .GlobalEnv, package:testpkg, package:stats, package:graphics,
 package:grDevices, package:utils, package:datasets, package:methods,
 Autoloads, package:base
 
 John Maindonald email: [EMAIL PROTECTED]
 phone : +61 2 (6125)3473fax  : +61 2(6125)5549
 Centre for Mathematics  Its Applications, Room 1194,
 John Dedman Mathematical Sciences Building (Building 27)
 Australian National University, Canberra ACT 0200.
 
 __
 R-devel@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-devel
 
 


-- 
Brian D. Ripley,  [EMAIL PROTECTED]
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] Inspecting promises

2007-09-23 Thread Gabor Grothendieck
Is there some way of displaying the expression and evaluation environment
associated with a promise?   I have found the following:

 # first run these two commands to set up example
 e - new.env()
 delayedAssign(y, x*x, assign.env = e)

 # method 1.  shows expression but not evaluation environment
 str(as.list(e))
List of 1
 $ y: promise to  language x * x

 # method 2. shows expression but not evaluation environment
 substitute(y, e)
x * x

which shows two different ways of displaying the expression
associated with a promise but neither shows the evaluation
environment.  The first technique may actually be a bug in
R based on previous discussion on r-devel.

Is there a way to display both the expression and the evaluation
environment associated with a promise.  Its a bit difficult to debug
code involving promises if you can't inspect the objects you are
working with.

 R.version.string # Vista
[1] R version 2.6.0 beta (2007-09-19 r42914)

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