[Rd] write.csv (PR#7992)

2005-07-06 Thread arnima
The write.csv() function is currently implemented as

   function (..., col.names=NA, sep=",", qmethod="double")
   {
 write.table(..., col.names=NA, sep=",", qmethod="double")
   }

Surely, it should be

   function (..., col.names=NA, sep=",", qmethod="double")
   {
 write.table(..., col.names=col.names, sep=sep, qmethod=qmethod)
   }

so that the user arguments serve a purpose. This notion is reflected in 
the implementation of read.csv(), for example, where sep=sep, quote=quote, 
etc.


Arni

R 2.1.1pat 2005-07-04 on WinXP

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


[Rd] SSD() documentation (PR#7993)

2005-07-06 Thread arnima
There are a couple of harmless typos in the documentation for the 
stats::SSD function, where

  "varianve" should be "variance"

  "followint" should be "following"


Arni

R 2.1.1pat 2005-07-04 on WinXP

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


[Rd] yaxs in bxp() (PR#8072)

2005-08-16 Thread arnima
It would be easy to add 'yaxs' support to bxp(), which can aid visual 
comparison when the lower limit is zero. The two lines from boxplot.R that 
would change are:


  plot.window(ylim=c(0.5,n+0.5), xlim=ylim, log=log)
to
  plot.window(ylim=c(0.5,n+0.5), xlim=ylim, xaxs=pars$yaxs, log=log)

and

  plot.window(xlim=c(0.5,n+0.5), ylim=ylim, log=log)
to
  plot.window(xlim=c(0.5,n+0.5), ylim=ylim, yaxs=pars$yaxs, log=log)


Boxplots already respond to a global par(yaxs="i"), and I think users 
would appreciate support for the local graphical parameter as well.

Thanks,
Arni

R 2.1.1-patched on WinXP

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


[Rd] pch=NA in bxp.Rd (PR#8073)

2005-08-16 Thread arnima
I'd like to iterate my earlier request (#7737) to change the documentation 
for bxp().

The argument outpch=" " needs to be replaced with outpch=NA in two places.

I actually wrote this part of the documentation myself at one point, but 
have now realized that pch=NA and pch=" " are not the same:

   x <- split(rlnorm(26e4), letters)
   ## NA generates small file
   postscript("na.ps");boxplot(x,outpch=NA);  dev.off()
   ## Space generates large file
   postscript("space.ps"); boxplot(x,outpch=" "); dev.off()

Thank you,
Arni

R 2.1.1-patched on WinXP

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


[Rd] bxp.Rd typo (PR#8153)

2005-09-23 Thread arnima
Hi. There's a minor typo in bxp.Rd:

whiskco:l
  should be
whiskcol:

Cheers,
Arni

R 2.1.1pat on WinXP

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


[Rd] pairs(oma) warnings (PR#8252)

2005-10-25 Thread arnima
Unlike R 2.1.1, version 2.2.0 generates warnings when an 'oma' argument as 
passed to pairs():

  A <- rnorm(100)
  B <- rnorm(100)
  pairs(cbind(A,B))# no warning
  pairs(cbind(A,B), oma=c(6,8,10,12))  # warnings in R 2.2.0

I think pairs() should draw the plot quietly, without warnings. Can't see 
anything in the documentation indicating that an 'oma' argument should not 
be passed in this way.

Thanks,
Arni

R 2.2.0pat on WinXP

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


[Rd] weighted.mean uses zero when na.rm=TRUE (PR#14032)

2009-10-30 Thread arnima
The weighted.mean() function replaces NA values with 0.0 when the user 
specifies na.rm=TRUE:

   x <- c(101, 102, NA)
   mean(x, na.rm=TRUE) # 101.5, correct
   weighted.mean(x, na.rm=TRUE)# 67.7, wrong
   weighted.mean(x, w=c(1,1,1), na.rm=TRUE)# 67.7, wrong
   weighted.mean(x, w=c(1,1,1)/3, na.rm=TRUE)  # 67.7, wrong

The weights are normalized w<-w/sum(w) before removing the NA values, 
effectively replacing x[is.na(x)]<-0. This bug was introduced between 
versions 2.9.2 and 2.10.0.

Thanks,

Arni

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


[Rd] Alphanumeric tools::file_path_sans_ext() (PR#14050)

2009-11-09 Thread arnima
The file_path_sans_ext() function in the 'tools' package does not handle 
alphanumeric file extensions correctly:

   require(tools)
   file_path_sans_ext("song.txt")  # song, correct
   file_path_sans_ext("song.mp3")  # song.mp3, wrong

The help page states that "only purely alphanumeric extensions are 
recognized", which I had expected. To fulfill this, the function body 
should be

   sub("([^.]+)\\.[[:alnum:]]+$", "\\1", x)

instead of the current definition:

   sub("([^.]+)\\.[[:alpha:]]+$", "\\1", x)

Thanks,

Arni

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


[Rd] Model frame when LHS is cbind (PR#14189)

2010-01-18 Thread arnima
The model frame shows the response and predictors in a data frame with
nicely labelled columns:

  fm <- lm(wt~qsec+log(hp)+sqrt(disp), data=mtcars)
  model.frame(fm)  # ok

When the left hand side consists of more than one response, those response
variables still look good, inside a matrix:

  fm <- lm(cbind(qsec,hp,disp)~wt, data=mtcars)
  model.frame(fm)[[1]]  # ok

A problem arises when some of the response variables are transformed:

  fm <- lm(cbind(qsec,log(hp),sqrt(disp))~wt, data=mtcars)
  model.frame(fm)[[1]]  # ugh, missing column names

The model frame is useful for many things, even more so when all column
names are legible. Therefore I propose adding two new lines to
model.frame.default() between lines 371 and 372 in
R-patched_2010-01-12/src/library/stats/R/models.R:

varnames <- sapply(vars, deparse, width.cutoff = 500)[-1L]
variables <- eval(predvars, data, env)

NEW if (is.matrix(variables[[1L]]))
NEW colnames(variables[[1L]]) <- as.character(formula[[2L]])[-1L]

if (is.null(rownames) && (resp <- attr(formula, "response")) >
0L) {

With this fix, the above example returns legible column names:

  fm <- lm(cbind(qsec,log(hp),sqrt(disp))~wt, data=mtcars)
  model.frame(fm)[[1]]  # nice column names

I hope the R development team can either commit this fix or improve it.

Thanks,

Arni

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


[Rd] Matrix dimnames crash (PR#13361)

2008-12-03 Thread arnima
In Windows XP, the matrix() function crashes the program when 'dimnames' 
is an empty list:

   matrix(1:4, nrow=2, dimnames=list())
   # R has encountered a problem and needs to close ...

This bug is specific to WinXP, as Linux64 handles this situation more 
gracefully:

   matrix(1:4, nrow=2, dimnames=list())
   Error in matrix(1:4, nrow = 2, dimnames = list()) :
 invalid type (environment) for 'dimnames' (must be a vector)

Thanks,
Arni

R 2.8.0-patched on WinXP

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


[Rd] boxplot ignores 'boxfill' (PR#9352)

2006-11-08 Thread arnima
The boxplot.default() function ignores argument 'boxfill' passed by user:

 x <- rnorm(100)
 boxplot(x, boxfill="blue")
 boxplot(x, pars=list(boxfill="green"))

As the original creator of the 'boxfill' argument, I'd like to propose the 
following change to the if(plot) clause in boxplot.R:

 if(plot) {
 if(is.null(pars$boxfill) && is.null(args$boxfill))
 pars$boxfill <- col
 do.call("bxp",
 c(list(z, notch=notch, width=width, varwidth=varwidth,
 outline=outline, log=log, border=border, pars=pars,
 horizontal=horizontal, add=add, at=at), args[namedargs]))
 invisible(z)
 }


What I've done is (1) setting boxfill=col only when that is desired, (2) 
named the 'width' list element to avoid confusion, and (3) rearranged the 
list so it has the same order as args(bxp).

Thanks,
Arni

R 2.4.0-patched on WinXP

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