Re: [Rd] (PR#14181) Error description not prompted but R crashes

2010-01-13 Thread pdemoulin
2010/1/12 Simon Urbanek 

> Even worse, this is a known bug long fixed in R 2.10.1 and hence a doubly
> pointless report ...
> Cheers,
> Simon
>
>
> You're right... have not seen that my daughter has a more recent version.
Download 2.10.1 from KUL-Leuven mirror on my G5 and all is fine: you can
close the ticket
Thanks for this follow-up
Phil

[[alternative HTML version deleted]]

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


Re: [Rd] seq.int broken (seq as well) (PR#14169)

2010-01-13 Thread Barry Rowlingson
2010/1/11 Jens Oehlschlägel :
> Petr,
> This can have severe consequences like accessing beyond the limits of an 
> array. If C-code is involved, this can crash R. In the worst case algorithms 
> can silently do wrong. Being an admirer of R since its early days, I was 
> shocked to see this, and as a consequence, I suggest we do our homework and 
> suspend -- for a year or two -- any claims that R can be used productive such 
> as SAS.

 Invalid Argument Error

 What does SAS do in these cases? How do you know? How do you know if
your SAS code isn't silently doing wrong? How do you know what caused
your SAS session to crash? How do you know what algorithms SAS uses
deep down inside?

 R gives you the source code, you can find these things out. The great
irony here is that SAS have "THE POWER TO KNOW" as a registered
trademark.

 Perhaps The R Foundation should trademark "THE POWER TO LEARN"?

Barry

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


Re: [Rd] Lightweight 'package' idea.

2010-01-13 Thread Keith Jewell
Going back a few months
I also thought "it would be nice if R had built into it some way of running 
code in source packages possibly with degraded functionality to ease 
development"
so building on Barry Rowlingsons start I came up with this:
---
loadDir <- function(.Root = choose.dir(getwd())){
   require(tools, quietly=TRUE) # for Rd2HTML
  .Package = basename(.Root)  # package name defined by directory name
  while(sum(search()==.Package)>0) detach(pos=which(search()==.Package)[1]) 
# if already attached, detach
  attach(NULL, name=.Package) # attach empty environment
  assign(".Root", .Root, pos=.Package) # insert .Root into .Package
# create reloadDir function and add into .Package
  reloadDir <- function(.Package) { # .Package must be character
for (f in list.files(path=file.path(get(".Root", pos=.Package) , "R"), 
# path is .Root/R/
   pattern=".R$",full.names=TRUE,recursive=TRUE,ignore.case=TRUE)) 
# file type = .R
   sys.source(f, envir=as.environment(.Package))   # source all such 
files into .Package
   invisible(.Package)} # invisibly return package name
  assign(x = "reloadDir", value = reloadDir, pos=.Package)
# create help.'.Package' function and add into package
#   (because function is created here, current value of .Root is in its 
environment)
  help.Package <- function(subj=""){# default subject is blank
  if (substitute(subj)=="") subj = "*" else subj <- paste("*", 
substitute(subj), "*", sep="")  # get *subj*' as character
  hfile <- list.files(path=file.path(.Root, "man"), # path is .Root/man/
pattern=paste(subj,"Rd$", sep="."),   # file = subj.Rd
full.names=TRUE,recursive=TRUE,ignore.case=TRUE) # list of matching 
files
  if (length(hfile) != 1)   # if not exactly one file, choose one
hfile <- choose.files(file.path(.Root, "man", paste(subj,"Rd", 
sep=".")), multi=FALSE)
  if(hfile != "") { # if exactly one file, open it
if(length(grep(".Rd$", hfile, ignore.case=TRUE)) ==1) { # if it's an 
Rd file, create/update html
   outfile <- sub("Rd$", "html", hfile, ignore.case=TRUE)  # name of 
corresponding html
   Rd2HTML(hfile, sub("Rd$", "html", hfile, ignore.case=TRUE), 
.Package)   # convert Rd to html
   hfile <- sub("Rd$", "html", hfile, ignore.case=TRUE)} # point to 
html
shell.exec(shQuote(hfile))} # use operating system to open file of 
any type
invisible(hfile)}# invisibly return help file name
  assign(x = paste("help", .Package, sep="."), value=help.Package, 
pos=.Package)
# use the reloadDir function to populate the environment
  reloadDir(.Package)
  invisible(.Package)  # invisibly return .Package name
   }
---
and a corresponding .Rd file

\name{loadDir}
\alias{reloadDir}
\alias{help.Package}
\title{Load an unbuilt package}
\description{
Loads code from a packages \file{\\R} subdirectory and gives access to help 
files in the packages
 \file{\\man} subdirectory (translating \file{.Rd} files to \file{.html}).
}
\usage{
loadDir(.Root = choose.dir(getwd()))
reloadDir(.Package)
help.'.Package'(subj="")
}
\arguments{
  \item{.Root}{character, scalar. The package directory (containing 
subdirectories \file{\\R} and \file{\\man}). \cr
\code{basename(.Root)} is taken as the package name 
(\code{.Package}).}
  \item{.Package}{character, scalar. Package name to be reloaded}
  \item{subj}{character, scalar. File name to be searched for in 
\file{\\man} subdirectory}
}
\details{ \describe{
\item{\code{loadDir}}{ attaches an environment at the second position on the 
search list with name \code{basename(.Root)} (after detaching any existing 
entries with that name). Into that environment it sources all \file{.R} 
files in the \file{\\R} subdirectory, searching recursively. \cr
In that environment it also places \code{.Root} and \code{.Package 
<-basename(.Root)} so that \code{get(".Root", pos=.Package)} can be used to 
retrieve the original file path. \cr
In that environment it also places function \code{reloadDir} (q.v.) \cr
In that environment it also places a function named '\code{help.}' followed 
by the name of the package (see \code{help.'.Package'})}
\item{\code{reloadDir}}{ re-sources all \file{.R} files in the packages 
\file{\\R} subdirectory, searching recursively.}
\item{\code{help.'.Package'}}{ recursively searches the packages 
\file{\\man} subdirectory for files named \code{subj}, initially searching 
for files of type \file{.Rd}. \cr
If there is not exactly one such file it opens a \code{file.choose} dialog 
to choose a single file of any type. \cr
If the single file is of type \file{.Rd} it is translated to a 
correspondingly named \file{.html} file in the same folder, which is opened 
by the operating system's file associations. \cr
If the file chosen is of any other type it is opened by the operating 
system's file associations.} }}
\value{ \d

[Rd] bug in callNextMethod (PR#14185)

2010-01-13 Thread bernd_bischl
Hi,

there seems to be a possible bug in callNextMethod in conjunction with 
the [-operator.

Relevant info, minimal example and sessionInfo follow below:

###

setClass("foo", representation = representation(a = "numeric"))
setClass("bar", contains = "foo")

setMethod(
f = "[",
signature = signature("foo"),
def = function(x,i,j,...,drop=TRUE) {
cat("drop in foo-[ :", drop, "\n")
return(1)
}
)

setMethod(
f = "[",
signature = signature("bar"),
def = function(x,i,j,...,drop=TRUE) {
cat("drop in bar-[ :", drop, "\n")
# we lose the value of drop here, when the call gets 
dispatched to the super method by callNextMethod
callNextMethod()
}
)

x <- new("foo")
x[1, drop=FALSE]
# drop in foo-[ : FALSE
y <- new("bar")
y[1, drop=FALSE]
# drop in bar-[ : FALSE
# drop in foo-[ : TRUE 

###

#?callNextMethod
#The statement that the method is called with the current arguments is 
more precisely as follows. Arguments that were missing in the current 
call are still missing (remember that "missing" is a valid class in a 
method signature). For a formal argument, say x, that appears in the 
original call, there is a corresponding argument in the next method call 
equivalent to x = x. In effect, this means that the next method sees the 
same actual arguments, but arguments are evaluated only once.

###


#S3 gets this right:

'[.foo' <- function(x, i, j, ..., drop=TRUE) {
cat("drop in foo-[ :", drop, "\n")
}
   
'[.bar' <- function(x, i, j, ..., drop=TRUE) {
cat("drop in bar-[ :", drop, "\n")
NextMethod()
}

x <- 1
class(x) <- c("bar", "foo")
x[1, drop=FALSE]
# drop in bar-[ : FALSE
# drop in foo-[ : FALSE

###

 > sessionInfo()
R version 2.11.0 Under development (unstable) (2010-01-12 r50970)
i386-pc-mingw32

locale:
[1] LC_COLLATE=German_Germany.1252  LC_CTYPE=German_Germany.1252  
[3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C  
[5] LC_TIME=German_Germany.1252   

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

loaded via a namespace (and not attached):
[1] tools_2.11.0

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


[Rd] Is this "strftime" behavior (on WinXP) what's expected?

2010-01-13 Thread Galkowski, Jan
WinXP, R version 2.10.1:

> s1<- strftime("2009/12/15 11:55:00 PM", format="%Y/%m/%d %I:%M:%S %p", 
> tz="GMT", usetz=FALSE)
> print(s1)
[1] "2009/12/15 11:55:00 AM"

> s2<- strftime("2009/12/16 12:00:00 AM", format="%Y/%m/%d %I:%M:%S %p", 
> tz="GMT", usetz=FALSE)
> print(s2)
[1] "2009/12/16 12:00:00 PM"

> s3<- strftime("2009/12/16 00:00:00 AM", format="%Y/%m/%d %I:%M:%S %p", 
> tz="GMT", usetz=FALSE)
> print(s3)
[1] "2009/12/16 12:00:00 AM"
>

-- 
Jan Galkowski, 617.444.4995 
   
  ""Eppur si muove." --Galilei 




[[alternative HTML version deleted]]

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


[Rd] Rd output garbled in some circumstances

2010-01-13 Thread Ross Boylan
I'm having trouble getting correct help output in some circumstances for
a package I've created. Though this is not an issue with the current R,
I would like my package to work with previous ones as well.

I'm looking for suggestions about how I could rework my .Rd file so that
it will work with prior R's.  In particular, R 2.7 is in the latest
stable release of Debian, so I'd like to solve the problem for 2.7.

The .Rd file is for a function and has an arguments section like this
\arguments{
  \item{formula}{ A formula giving the vectors containing
## skipped
covariates.  }
## skipped
  \item{stepdenominator}{See \code{stepnumerator} just above.}
  
  \item{do.what}{\describe{
\item{1}{By default, calculates a maximimum likelihood.  To evaluate
  a single likelihood, set all parameters to fixed. }
\item{0}{Count number of paths and related statistics without
  evaluating the likelihood.}
\item{-1}{Get detailed counts (but no likelihoods) associated with
  each case.  The return value is a matrix.}
\item{10}{Use the model to generate a random path for each
  case. returning a \code{data.frame} with simulated observed states
  and times and all other data as observed.}
}}

  \item{testing}{This argument is  only for use by developers.  Set it
## etc

This comes out fine in a pdf, but ?mspath (the function) produces, in
part,

stepdenominator: See 'stepnumerator' just above.

 1 By default, calculates a maximimum likelihood.  To evaluate a
  single likelihood, set all parameters to fixed. 

 0 Count number of paths and related statistics without evaluating
  the likelihood.

in R 2.7.  The "do.what" header has vanished.  In R 2.10 it's fine.

Is there an error in my documentation format?
Even if not, is there some change I could make that would get R 2.7 to
work better?

The R change log doesn't show anything obviously related to this, though
it has several references to unspecified fixes to the documentation
system.  I also tried looking at the bug tracker, but couldn't find
anything--in fact I had trouble identifying bugs in the documentation
system as opposed to bugs in the documentation.

Thanks.
Ross Boylan

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


Re: [Rd] bug in callNextMethod (PR#14185)

2010-01-13 Thread John Chambers
Yes, a bug prevented callNextMethod() from detecting the special case of 
the `[` call, for which it did have code.


Should be fixed in the current 2.11.0 (r 50976).

Thanks for the helpful bug report.

John Chambers

bernd_bis...@gmx.net wrote:

Hi,

there seems to be a possible bug in callNextMethod in conjunction with 
the [-operator.


Relevant info, minimal example and sessionInfo follow below:

###

setClass("foo", representation = representation(a = "numeric"))
setClass("bar", contains = "foo")

setMethod(
f = "[",
signature = signature("foo"),
def = function(x,i,j,...,drop=TRUE) {
cat("drop in foo-[ :", drop, "\n")
return(1)
}
)

setMethod(
f = "[",
signature = signature("bar"),
def = function(x,i,j,...,drop=TRUE) {
cat("drop in bar-[ :", drop, "\n")
# we lose the value of drop here, when the call gets 
dispatched to the super method by callNextMethod

callNextMethod()
}
)

x <- new("foo")
x[1, drop=FALSE]
# drop in foo-[ : FALSE
y <- new("bar")
y[1, drop=FALSE]
# drop in bar-[ : FALSE
# drop in foo-[ : TRUE 


###

#?callNextMethod
#The statement that the method is called with the current arguments is 
more precisely as follows. Arguments that were missing in the current 
call are still missing (remember that "missing" is a valid class in a 
method signature). For a formal argument, say x, that appears in the 
original call, there is a corresponding argument in the next method call 
equivalent to x = x. In effect, this means that the next method sees the 
same actual arguments, but arguments are evaluated only once.


###


#S3 gets this right:

'[.foo' <- function(x, i, j, ..., drop=TRUE) {
cat("drop in foo-[ :", drop, "\n")
}
   
'[.bar' <- function(x, i, j, ..., drop=TRUE) {

cat("drop in bar-[ :", drop, "\n")
NextMethod()
}

x <- 1
class(x) <- c("bar", "foo")
x[1, drop=FALSE]
# drop in bar-[ : FALSE
# drop in foo-[ : FALSE

###

 > sessionInfo()
R version 2.11.0 Under development (unstable) (2010-01-12 r50970)
i386-pc-mingw32

locale:
[1] LC_COLLATE=German_Germany.1252  LC_CTYPE=German_Germany.1252  
[3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C  
[5] LC_TIME=German_Germany.1252   


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


loaded via a namespace (and not attached):
[1] tools_2.11.0

__
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] Rd output garbled in some circumstances

2010-01-13 Thread Duncan Murdoch

On 13/01/2010 6:15 PM, Ross Boylan wrote:

I'm having trouble getting correct help output in some circumstances for
a package I've created. Though this is not an issue with the current R,
I would like my package to work with previous ones as well.

I'm looking for suggestions about how I could rework my .Rd file so that
it will work with prior R's.  In particular, R 2.7 is in the latest
stable release of Debian, so I'd like to solve the problem for 2.7.

The .Rd file is for a function and has an arguments section like this
\arguments{
  \item{formula}{ A formula giving the vectors containing
## skipped
covariates.  }
## skipped
  \item{stepdenominator}{See \code{stepnumerator} just above.}
  
  \item{do.what}{\describe{

\item{1}{By default, calculates a maximimum likelihood.  To evaluate
  a single likelihood, set all parameters to fixed. }
\item{0}{Count number of paths and related statistics without
  evaluating the likelihood.}
\item{-1}{Get detailed counts (but no likelihoods) associated with
  each case.  The return value is a matrix.}
\item{10}{Use the model to generate a random path for each
  case. returning a \code{data.frame} with simulated observed states
  and times and all other data as observed.}
}}

  \item{testing}{This argument is  only for use by developers.  Set it
## etc

This comes out fine in a pdf, but ?mspath (the function) produces, in
part,

stepdenominator: See 'stepnumerator' just above.

 1 By default, calculates a maximimum likelihood.  To evaluate a
  single likelihood, set all parameters to fixed. 


 0 Count number of paths and related statistics without evaluating
  the likelihood.

in R 2.7.  The "do.what" header has vanished.  In R 2.10 it's fine.

Is there an error in my documentation format?
Even if not, is there some change I could make that would get R 2.7 to
work better?


I would avoid nesting the \describe within \arguments.  Both basically 
use the same formatting code, and 2.7 probably doesn't support nesting 
properly.  There was no real parser there, just a fallible pattern 
matching approach.


A better solution is to say your package requires a recent version of R, 
but maybe that's not feasible for you.


Duncan Murdoch



The R change log doesn't show anything obviously related to this, though
it has several references to unspecified fixes to the documentation
system.  I also tried looking at the bug tracker, but couldn't find
anything--in fact I had trouble identifying bugs in the documentation
system as opposed to bugs in the documentation.

Thanks.
Ross Boylan

__
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] Mksetup() limited to hashing with 32 bits

2010-01-13 Thread Benjamin Tyner
The MKsetup() in unique.c throws an error if the vector to be hashed is 
longer than (2^32)/8:


   if(n < 0 || n > 536870912) /* protect against overflow to -ve */
   error(_("length %d is too large for hashing"), n);

I occasionally work with vectors longer than this on 64-bit builds. Would it be 
too much to ask that R can take advantage of all 64 bits for hashing when 
compiled as such?

Thanks
Ben

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