warning message for setAs when using class AsIs
David Kane <David Kane
a296180@agate.fmr.com
Wed, 29 May 2002 10:33:19 -0400
This seemed too advanced for r-help and is related to the recent discussion of
character vectors in dataframes.
Following Brian Ripley's most excellent advice, we are moving to a world in
which character vectors in dataframes are always of class AsIs. The cool way of
doing this seemed to be the following:
> cat(c("x", "y", "z"), file = "test.txt", sep = "\n")
> x <- read.table("test.txt")
> class(x$V1)
[1] "factor"
This is what we expect.
> library(methods)
> setAs('character', "AsIs", function(from) I(from))
Warning message:
Class "AsIs"not defined in: matchSignature(fnames, signature, fdef)
>
This warning seems wrong to me, although I am not smart enough to follow the
logic through the underlying code. It *seems* as if setAs does not consider
`AsIs' to be an allowed class. However, the desired effect is achieved.
> x <- read.table("test.txt", colClasses=c("AsIs"))
> x
V1
1 x
2 y
3 z
> class(x$V1)
[1] "AsIs" "character"
> unlink("test.txt")
> R.version
_
platform sparc-sun-solaris2.6
arch sparc
os solaris2.6
system sparc, solaris2.6
status
major 1
minor 5.0
year 2002
month 04
day 29
language R
>
Any comments/suggestions would be much appreciated.
Thanks,
Dave Kane
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._