[Rd] "[.data.frame" forgets about "AsIs" (PR#665)

maechler@stat.math.ethz.ch maechler@stat.math.ethz.ch
Thu, 21 Sep 2000 17:56:31 +0200 (MET DST)


>>>>> "MM" == Martin Maechler <maechler@stat.math.ethz.ch> writes:

    MM> Short example:
    >> str(d <- data.frame(a = I(letters[1:5])))
    MM> `data.frame':	5 obs. of  1 variable:
    MM> $ a:Class 'AsIs'  chr [1:5] "a" "b" "c" "d" ...
    >> str(d[TRUE,,drop = FALSE])
    MM> `data.frame':	5 obs. of  1 variable:
    MM> $ a: chr  "a" "b" "c" "d" ...

    MM> The real problem about this is, that as soon as the data.frame is
    MM> further "transformed", the character component is coerced to a
    MM> factor, e.g.

    >> str(rbind(d[TRUE,,drop = FALSE], "E"))
    MM> `data.frame':	6 obs. of  1 variable:
    MM> $ a: Factor w/ 6 levels "a","b","c","d",..: 1 2 3 4 6 5


Probably the cleanest fix is the addition of 

  "[.AsIs" <- function(x, i) structure(NextMethod("["), class = class(x))

--
Will go into R-devel unless someone has a better idea.

Martin Maechler <maechler@stat.math.ethz.ch>	http://stat.ethz.ch/~maechler/
Seminar fuer Statistik, ETH-Zentrum  LEO D10	Leonhardstr. 27
ETH (Federal Inst. Technology)	8092 Zurich	SWITZERLAND
phone: x-41-1-632-3408		fax: ...-1228			<><

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel 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-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._