Hello All,
I would like to be able to convert and S4 class to an array but I seem to be
stuck. Reading the documentation I think I need to use setAs() and then as()
Below is a minimal example but I cannot get it to work. So I am doing
something wrong but I don't know what it is.
Any insights/help are appreciated,
- Glenn
setClass("AnObject",
representation(
dataone = "numeric",
datatwo = "numeric"))
FillObject <- function(){
one <- rep(10, 20)
two <- rep(10,20)
new("AnObject",
dataone = one,
datatwo = two)
}
MyObject <- FillObject()
setAs(from = "AnObject" , to = "array", def = function(from) from(AnObject))
NewObject <- as(MyObject, "array")
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.