[R] Linked List in R

Shing Hing Man matmsh at yahoo.com
Sat Feb 12 20:08:12 CET 2011


Hi,
  I am trying to create a linked list in R by defining a class Node which has a instance variable Node.

setClass("Node", representation(rate="numeric",  nextNode="ANY"))

The above works. But the following gives me a warning message.
setClass("Node", representation(rate="numeric",  nextNode="Node"))


>
> setClass("Node", representation(rate="numeric",  nextNode="ANY"))
[1] "Node"
> removeClass("Node")
[1] TRUE
>
> setClass("Node", representation(rate="numeric",  nextNode="Node"))
[1] "Node"
Warning message:
undefined slot classes in definition of "Node": nextNode(class "Node")
>

In the case when nextNode is type Node, is it possible to get ride of the above  "undefined slot classes" warning message ?


Thanks in advance for any assistance!

Shing 






More information about the R-help mailing list