[Rd] switch() called with just the EXPR argument causes R to hang (PR#14124)

2009-12-10 Thread sgiannerini
Dear all,

switch() called with just the EXPR argument causes R to hang so that the
only way to stop it is to kill R.

Reproducible example:

> switch(EXPR="a")

the internal C subroutine behind switch is do_switch located in
R/src/main/builtin.c
For convenience I reproduce it below.

*
SEXP attribute_hidden do_switch(SEXP call, SEXP op, SEXP args, SEXP rho)
{
int argval;
SEXP x, y, w;
x = eval(CAR(args), rho);
if (!isVector(x) || length(x) != 1)
error(_("switch: EXPR must return a length 1 vector"));
PROTECT(w = switchList(CDR(args), rho));
if (isString(x)) {
for (y = w; y != R_NilValue; y = CDR(y))
if (TAG(y) != R_NilValue && pmatch(STRING_ELT(x, 0), TAG(y), 1)) {
while (CAR(y) == R_MissingArg && y != R_NilValue)
y = CDR(y);
UNPROTECT(1);
return (eval(CAR(y), rho));
}
for (y = w; y != R_NilValue; y = CDR(y))
if (TAG(y) == R_NilValue) {
UNPROTECT(1);
return (eval(CAR(y), rho));
}
UNPROTECT(1);
return R_NilValue;
}
argval = asInteger(x);
if (argval <= 0 || argval > (length(w))) {
UNPROTECT(1);
return R_NilValue;
}
x = eval(CAR(nthcdr(w, argval - 1)), rho);
UNPROTECT(1);
return x;
}
**

I do not know C but it seems to me that do_switch expects two arguments.

regards

Simone

tested both on Windows VISTA 32 bit

platform   i386-pc-mingw32
arch   i386
os mingw32
system i386, mingw32
status
major  2
minor  10.0
year   2009
month  10
day26
svn rev50208
language   R
version.string R version 2.10.0 (2009-10-26)

and on Linux OpenSuSE 11.0 64bit

> R.version
   _
platform   x86_64-unknown-linux-gnu
arch   x86_64
os linux-gnu
system x86_64, linux-gnu
status Patched
major  2
minor  10.0
year   2009
month  11
day19
svn rev50499
language   R
version.string R version 2.10.0 Patched (2009-11-19 r50499)


-- 
__

Simone Giannerini
Dipartimento di Scienze Statistiche "Paolo Fortunati"
Universita' di Bologna
Via delle belle arti 41 - 40126  Bologna,  ITALY
Tel: +39 051 2098262  Fax: +39 051 232153
http://www2.stat.unibo.it/giannerini/
__

[[alternative HTML version deleted]]

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


[Rd] Bug in pacf -- Proposed patch (PR#10455)

2007-11-23 Thread sgiannerini
Dear all,

following the thread

http://tolstoy.newcastle.edu.au/R/e2/devel/07/09/4338.html

regarding the bug in the partial autocorrelation function for
multivariate time series.
I have prepared a web page with patches and relevant information.

http://www2.stat.unibo.it/giannerini/R/pacf.htm

Please do not hesitate to contact me for further clarifications

regards

Simone

-- 
__

Simone Giannerini
Dipartimento di Scienze Statistiche "Paolo Fortunati"
Universita' di Bologna
Via delle belle arti 41 - 40126  Bologna,  ITALY
Tel: +39 051 2098262  Fax: +39 051 232153
http://www2.stat.unibo.it/giannerini/

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


[Rd] quantile and IQR do not check for numeric input (PR#13631)

2009-03-30 Thread sgiannerini
This report follows the post

http://tolstoy.newcastle.edu.au/R/e6/devel/09/03/0760.html

where it is shown that quantile() and IQR() do not work as documented.
In fact they do not check for numeric input even if the documentation says =
:

?quantile
x  numeric vectors whose sample quantiles are wanted. Missing
values are ignored.

?IQR

x   a numeric vector.

> quantile(factor(1:9))
  0%  25%  50%  75% 100%
   13579
Levels: 1 2 3 4 5 6 7 8 9

> IQR(factor(1:9))
[1] 4

> R.version
   _
platform   i386-pc-mingw32
arch   i386
os mingw32
system i386, mingw32
status alpha
major  2
minor  9.0
year   2009
month  03
day26
svn rev48224
language   R
version.string R version 2.9.0 alpha (2009-03-26 r48224)

--
__

Simone Giannerini
Dipartimento di Scienze Statistiche "Paolo Fortunati"
Universita' di Bologna
Via delle belle arti 41 - 40126 =A0Bologna, =A0ITALY
Tel: +39 051 2098262 =A0Fax: +39 051 232153
http://www2.stat.unibo.it/giannerini/

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