From murdoch.duncan at gmail.com  Tue Jul 26 20:53:54 2011
From: murdoch.duncan at gmail.com (Duncan Murdoch)
Date: Tue, 26 Jul 2011 14:53:54 -0400
Subject: [Rd] R result objects as lists
In-Reply-To: <86sjpt9i6s.fsf@googlemail.com>
References: <86sjpt9i6s.fsf@googlemail.com>
Message-ID: <4E2F0D42.7050906@gmail.com>

On 26/07/2011 11:26 AM, Thorsten wrote:
> Hello List,
> I want to communicate between a minimalistc lisp that has
> only numbers, symbols (also used as strings) and lists as datatypes, and R.
>
> It should be no problem to send command strings from the lisp process
> to the R childprocess.
>
> I know, R is mostly implemented in Scheme,

No, the design of the original R interpreter was based on a Scheme 
interpreter, but it is mostly implemented in C.

>   and I read recently, that
> these special return objects of R are really lists under the
> hood. Therefore my questions:
>
> 1. When I send a command from a lisp (that iks not elisp) to an R
> subprocess, how can I recieve the R result object as a list (and not a
> special R object)?
>
> 2. Apart from graphics - are all R result objects lists (or numbers or
> strings)? That is, is it safe to assume that the result of an R call
> will always be either a number, a string or a list (under the hood)?

No, you need to treat the results as C structures under the hood.  Some 
are implemented as Lisp-like lists, but most are vectors with additional 
information about the type of object that is contained within (in a 
C-style array).

Duncan Murdoch



[Rd] R result objects as lists
Duncan Murdoch