Hi Wojciech, Hi all,
there are some points I wish to discuss about Calc - R integration. The
licensing issue is brought up again and again, but I feel it is not so
relevant, as there are many other programs that use R. So, it is at
least solvable.
Probably, after reading this, one will better understand what I am
talking about.
In order to submit data from OOo Calc to R and back, the following steps
have to be made:
1. read the cell content from Calc and transform it into suitable R commands
2. channel this R command/data into R
3. channel the results back into Calc
4. interpret the results and paste/push them into the appropriate Calc cells
Well, I have NO idea about steps 2 and 3. It is doable, as we saw it in
the previous macro. These steps need also NOT necessary be LGPL. Some of
the code could be GPL and included as an R package.
STEP 1
=====
I will emphasize here steps 1 and 4 (though 4 is similar to 1, so I
won't specifically analyse it). These are the really crucial steps AND
they need to be inside Calc, so LGPL. [These steps are likely to be
independent of any implementation details for steps 2 and 3.]
In the previous macro, the first step was done using java. Actually,
this can easily be done in native C++ inside the Calc main codebase, so
this can be shipped with OOo under the LGPL license. NO problem here.
CALC CODE
==========
I have previously posted some code on the mailing list to perform an
ANOVA. I will post that code shortly to the following issue
(http://www.openoffice.org/issues/show_bug.cgi?id=4921, not yet posted),
so that it will be more easy to track. An even better way to learn more
about Calc code is probably to study the code for some of the native
functions. The documentation is awful, that's why I started issue 76575
which you may wish to read, too (see
http://www.openoffice.org/issues/show_bug.cgi?id=76575). The attached
spreadsheet document contains the names of (all?) Calc spreadsheet
functions including the parameters and return value. It also includes
the *module* where the function is defined.
Though there are still many issues undocumented, this is a timid first
step. Some of the function names are self explanatory, so viewing the
code may help you understand how to write the input handler. These
functions are defined in the files interpr1.cxx through interpr6.cxx
PIPELINES
=========
Actual, this first step I am talking about reflects a more general problem:
How to PIPELINE data from Calc into other applications.
R is just one example (for another one using gawk, see
http://www.openoffice.org/issues/show_bug.cgi?id=66816). There are many
more programs that could extend OOo Calc. So, building a robust pipeline
should be more thoroughly considered.
PROPER CODE
============
I imagine this implemented in the following way:
- write native Calc function (C++) that:
- iterates trough selected table cells
- reads cell content
- performs eventual 'missing values' => 'NA' substitutions
- creates a string using the R-syntax for vectors, frames and
matrices as required [e.g. var <- c(...) ]
- pipelines this string to the step 2 function/ routine
Hopefully, this will help.
Sincerely,
Leonard
Kohei Yoshida wrote:
Hi Wojciech,
On Sat, 2007-04-21 at 02:16 -0400, Wojciech Gryc wrote:
Thanks for the responses!
With regards to GPL / LGPL issues, I understand the macro code would be
under GPL, but is that okay from your end? I don't mind that license, but am
not sure how OO developers feel. :)
This is not a matter of how we feel, but a matter of licensing. :-) We
can't ship a GPL'ed code with OO.o because OO.o is LGPL. So, if your
component ends up released under GPL, then that will become an issue
that requires a resolution.
...
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]