Sherlock, Ric wrote:
I have been investigating interfacing J and R using Rserve.
<http://www.jsoftware.com/jwiki/Interfaces/R/Rserve>

I am interested in how best to go about working with the Attribute lists
returned by the interface. For example how would I best extract the list
called dist from the following structure?
Rget 'sapply(head(cars), list)'
+---------------------+-----------------------------+
|+------------+------+|+-----------+---------------+|
||+-----+----+|`names|||4 4 7 7 8 9|2 10 4 22 16 10||
|||speed|dist||      ||+-----------+---------------+|
||+-----+----+|      ||                             |
|+------------+------+|                             |
+---------------------+-----------------------------+

Or the levels for the structure on the wiki page?
<http://www.jsoftware.com/jwiki/Interfaces/R/Rserve/Examples>
+----------------------------------------------+-------+
|+--------------------+---------------+-------+|2 4 3 1|
||+----+---+-----+---+|+------+------+|`levels||       |
|||four|one|three|two|||factor|`class||       ||       |
||+----+---+-----+---+|+------+------+|       ||       |
|+--------------------+---------------+-------+|       |
+----------------------------------------------+-------+

Obviously one answer is to use R to get the bits I want.
Rget 'head(cars$dist)'  and Rget 'levels(x)
But I'm interested in how to work with these structures and symbols in
J.

I would prefer to work with the attribute lists from within J, since at least it should be more efficient to get everything in one go, rather than go back and forth down the R attribute list.

We need a dyadic verb, say Rgetattr, where x is a list of attributes and y the result of Rget. The result is the attributes, e.g.

   'names' Rgetattr Rget 'sapply(head(cars), list)'
+-----+----+
|speed|dist|
+-----+----+

A second verb Rgetattrs could then define all attributes as global variables. We could then associate a locale with an R variable.

When I first looked at this, I stopped here, because I was not sure of the exact representation of attributes. I had expected them to be a pair:

   value;`name

where `name is the attribute name, and value is the value, which itself may be an attribute or attribute list.

Your first example matches this. The second example does not, since the attribute is a 3 item list.

Do you know of an exact definition of attributes?

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to