On 06/03/2011 01:53 AM, Janko Thyson wrote:
On 31.05.2011 18:17, Martin Morgan wrote:
On 05/30/2011 07:02 AM, Janko Thyson wrote:
Dear list,

I would like to set one specific Reference Class field to be of an
arbitrary class. Is there a class that all R objects inherit from? I
thought that "ANY" was something like this, but obviously that's not
true:

> inherits(1:3, "ANY")
[1] FALSE

I can't speak to the implementation, but ANY functions as a base class
in terms of slot / field assignment and inheritance, e.g.,

setClass("A", representation(x="ANY"))
new("A", x=1:3)

Martin

Hi Martin,

sorry for the late response. The way you do it works. Yet, when you
declare dependencies more explicitly (contains=XY), then R complains. Is
this a feature or a bug (with respect to the "less explicit" way working
just fine)? See the example below:

# S4
setClass("A", representation(x="ANY"))
new("A", x=1:3)

setClass("A", representation(x="ANY"))
setClass("B", contains="A", representation(x="character"))
new("B", x=1:3)

# Reference Classes
setRefClass(
Class="A",
fields=list(
.PRIMARYDATA="ANY"
),
contains=c("VIRTUAL")
)
B <- setRefClass(
Class="B",
fields=list(
.PRIMARYDATA="character"
),
contains=c("A")
)

Bug, I'd say. Martin


Regards,
Janko

Regards,
Janko

[[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
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.




--
------------------------------------------------------------------------

*Janko Thyson*
janko.thy...@googlemail.com <mailto:janko.thy...@googlemail.com>

Jesuitenstraße 3
D-85049 Ingolstadt

Mobile: +49 (0)176 83294257

This e-mail and any attachment is for authorized use by the intended
recipient(s) only. It may contain proprietary material, confidential
information and/or be subject to legal privilege. It should not be
copied, disclosed to, retained or used by any other party.
If you are not an intended recipient then please promptly delete this
e-mail and any attachment and all copies and inform the sender.



--
Computational Biology
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109

Location: M1-B861
Telephone: 206 667-2793

______________________________________________
R-help@r-project.org mailing list
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.

Reply via email to