On Fri, 12 Dec 2008, Peter Dalgaard wrote:
Prof Brian Ripley wrote:
I have never seen the report in the repository. There were problems with
R-bugs at around that time (most email submission was stalled for a month
or so).
Maybe, but I don't see a PR# on _any_ of Martin Morgan's posts...
However, I think the problems are far more serious: the help page says
Returns a matrix of integers indicating their column number in a
matrix-like object.
...
as.factor: a logical value indicating whether the value should be
returned as a factor rather than as numeric.
Value:
An integer matrix with the same dimensions as 'x' and whose
'ij'-th element is equal to 'j'.
There is no mention of using the column labels as the values and the result
was not even a matrix. I certainly expected the factor levels to be
numeric.
I presume that the intention is to use the column labels (default
seq_len(nrow(x)) ) in place of the numbers, and to return a factor matrix,
so I have implemented that for col() and row().
However, I do wonder that anyone was using as.factor=TRUE given that it did
not do anything like what it was documented to.
There could, I suppose, be applications of the style
library(ISwR)
dd <- data.frame(count=c(caesar.shoe),
caesar=row(caesar.shoe,as.factor=TRUE),
size=col(caesar.shoe,as.factor=TRUE))
anova(glm(count~caesar*size,family=poisson,data=dd))
(as.data.frame.table is better in this case, I know). Notice that this will
break if you change the value to a factor matrix.
It is not clear that a matrix is desired -- an alternative point of view is
that when you request a factor, it is intended to be used along with
long-format data.
Yes, it is not clear (and I had given it some thought), but
a) a matrix result was documented and
b) it is easier to remove dims than add them (impossible without the
original matrix to hand).
On Mon, 8 Dec 2008, Dan Davison wrote:
This bug was reported to r-devel by Martin Morgan on 13th May 2008
(original email pasted below). However I couldn't locate it in the bug
tracker (with searches for row, col, as\.factor) It is still present
in today's svn version (rev 47115). I hope I'm doing something useful
by bringing it up again. I have not sent this to r-bugs, as I'm
concerned that not locating it in the bug tracker could be my failing.
--
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, UK Fax: +44 1865 272595
______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel