[R] apply and factor
Laurent Gautier
laurent at cbs.dtu.dk
Fri Aug 10 10:42:35 CEST 2001
Prof Brian D Ripley wrote:
>
> On Fri, 10 Aug 2001, Rachel Cunliffe wrote:
>
> > Hi again
> >
> > Why does this occur?
> >
> > > test <- apply(data,2,factor) # where data is a data.frame
> > > is.factor(test[,1])
> > [1] FALSE
>
> test is a *matrix*, see ?apply. No factors in matrices!
> Using `data' as a name is probably a bad idea in R: it's an important
> function name.
As R extends, the number of important function names is likely to keep
growing.
(And I have seen Pr. Ripley mentionning more than once that one was
overriding an important funcion).
A good mannered user should check the existance of a function before
choosing to giving a name... that may be not what is done...
I was thinking of a switch to warn the user of function overriding (the
switch could be somewhere in the options() ). The disavantage of such a
thing might be a slowdown of the execution R scripts, and most likely
may require a lot of implementation efforts, to set this in the existing
code, for a rather minor improvement. An another, and may be less
general, mecanism would be to have a special status for the functions of
R-base. Their overriding would require an explicit statement...
...Does this that make any sense ?
Regards,
Laurent
--
Laurent Gautier CBS, Building 208, DTU
PhD. Student D-2800 Lyngby,Denmark
tel: +45 45 25 24 85 http://www.cbs.dtu.dk/laurent
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list