Skip to content

warning message for setAs when using class AsIs

2 messages · a296180@agate.fmr.com (David Kane, John Chambers

#
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:
[1] "factor"

This is what we expect.
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.
V1
1  x
2  y
3  z
[1] "AsIs"      "character"
_                   
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
"David Kane
In the sense of the methods package (i.e., of "S4" classes) the class
"AsIs" and all S3-style classes are undefined.  Literally, in that there
is no object containing their definition.

In general, mixing old and new classes can cause confusion.  In this
case, you will be OK if the as() function finds a specific method to
coerce character to "AsIs".  The warning is saying that there won't be
any way to infer inheritance for the class "AsIs", but inheritance for
the target class is not important for the call to as().

John

PS: the current version of read.table implicitly requires the methods
package if the argument colClasses is supplied.  Should that be made
explicit?

Otherwise, users get errors if they forget library(methods):

R> x <- read.table("testR/test.txt", colClasses=c("AsIs"))
Error: couldn't find function "as"