[R] "methods" package changes class types?
Nunoo, Paa K
Paa.K.Nunoo at FMR.COM
Wed Jan 8 17:57:24 CET 2003
Loading the "methods" package into R seems to change the class of a
character vector from NULL to "character":
This can lead to problems. For example the "as.string" function in the
assumes that the class of a character vector is NULL. However this changes
when the methods
package is loaded.
Here is a code snippet of the as.string function in the xtable package:
function (x, file = "", append = FALSE)
switch(data.class(x), character = return(string(x, file,
append)), numeric = return(string(as.character(x),
file, append)), stop("Cannot coerse argument to a string"))
if (class(x) == "string")
stop("Cannot coerse argument to a string")
Why does the methods package change the class of character vectors?
Is there a way around this behavior?
More information about the R-help