Re: [sc-dev] R + Calc Update
Kohei Yoshida wrote: You may have already seen it, but there is also the scaddins module where you can add new functions. This module was there originally to ease addition of new cell functions without touching the Calc core, but I don't know if this module is actively used today (Niklas?). I wouldn't bother with this scaddins module though. I'd go with the UNO add-in component approach. The scaddins module is still used and contains functions that are included in the default installation. But, as mentioned, the R integration probably doesn't need any functions. Niklas - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [sc-dev] R + Calc Update
Niklas -- I'll focus on UNO components then. There will definitely be dialogs and visual guides for people, but I've been focusing on functions because I'd like to build something that can use any function in R, sort of like a very basic scripting process that can send anything to R and get the results back. The GUI could then use this function, rather than be confined to a dialog. Kohei -- Yes, I found your article incredibly useful - it was actually the first thing I read when I started exploring the OpenOffice source code. If I learn more new things, I'll write some more. Thanks, Wojciech On 5/2/07, Kohei Yoshida [EMAIL PROTECTED] wrote: On Tue, 2007-05-01 at 23:55 -0400, Wojciech Gryc wrote: A little off-topic now, but I wrote an article for the wiki on adding functions to the Calc code: http://wiki.services.openoffice.org/wiki/Hacking_Calc_-_Adding_Functions Cool! I'm actually glad to see someone did read my article, and decide to write a sequel. :-) The topic is good. We need more articles like that - articles that are focused more on hacking the core than just the UNO stuff. Kohei - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Five Minutes to Midnight: Youth on human rights and current affairs http://www.fiveminutestomidnight.org/
Re: [sc-dev] R + Calc Update
Hi Wojciech, These are just my views, but hopefully they will be useful in some way. :-) On Sun, 2007-04-29 at 18:23 -0400, Wojciech Gryc wrote: I guess what I am trying to get at is, how can I add functions to Calc through the source code? All the tutorials I've found are for add-ins. In my view, the best way to add new cell functions for this task are via UNO add-in component. A direct modification of the Calc source code is probably best left for built-in functions, IMO. 2. From your perspectives, should this be considered an add-in or directly coded into the sc folder? Is there any other area of the source code I should be working in? I wouldn't directly code into the sc module, because that would add a strong dependency on R. Adding new functions via UNO add-in component will have the same effect, and is probably much easier cleaner because it's pluggable. You may have already seen it, but there is also the scaddins module where you can add new functions. This module was there originally to ease addition of new cell functions without touching the Calc core, but I don't know if this module is actively used today (Niklas?). I wouldn't bother with this scaddins module though. I'd go with the UNO add-in component approach. 3. Any thoughts on the TCP/IP versus package-to-OO communication mentioned above? I think it might be a bit beyond the scope of the summer project, but I'd be happy to try to tackle it if there's interest. You can probably leave this part for now, and do it only when you have time left. As long as the code to connect to R is sufficiently isolated (aka modularized), rewriting that part to use TCP/IP can be done later. Hope this helps. Kohei -- Kohei Yoshida - OpenOffice.org Engineer - Novell, Inc. [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [sc-dev] R + Calc Update
Hi, Sound good. I'll worry about getting it to work rather than making it GPL-compatible. A little off-topic now, but I wrote an article for the wiki on adding functions to the Calc code: http://wiki.services.openoffice.org/wiki/Hacking_Calc_-_Adding_Functions Feel free to comment, add, etc. Thanks, Wojciech On 5/1/07, Kohei Yoshida [EMAIL PROTECTED] wrote: Hi Wojciech, On Tue, 2007-05-01 at 14:39 -0400, Wojciech Gryc wrote: Finally, I don't mind making a Calc add-in instead. I did notice the scaddins folder and actually toyed with the idea of using that instead. I just have a few questions about this: The code inside the scaddins module is not external, therefore *does* get distributed with OO.o. So, putting a GPL-code in the scaddins is probably not a good idea in this case. 1. How do we expect the user to install this stuff, in general? If I make a link between C and R, we can't ship it with OO due to licensing issues, so should we build some sort of built-in installer, or just have a link somewhere on the OO website? Initially, you could probably put your external R package somewhere on your website, sourceforge etc. that are separate from the OO.o website, then put a URL to it on the Calc page (or something). Later when the licensing issue gets resolved, we can put the code into the main tree. Anyway, we should probably come back to this topic later when we have something to distribute. ;-) 2. If I do make an add-in, is there anywhere I can put it in the source code, or will it be an external package, as discussed in #1? If it is an external package, then can I just code a link to R directly in the add-in? Yes. You'll need to release the package under GPL, of course, but as long as it's an external package, there shouldn't be any licensing issue (that I see). Hope this helps. Kohei -- Kohei Yoshida - OpenOffice.org Engineer - Novell, Inc. [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Five Minutes to Midnight: Youth on human rights and current affairs http://www.fiveminutestomidnight.org/
Re: [sc-dev] R + Calc Update
Hi, this is the answer for a similar question I once asked Niklas: Find the function name in sc/source/core/src/compiler.src, the corresponding OpCode value in sc/inc/opcode.hxx, and look in ScInterpreter::Interpret (sc/source/core/tool/interpr4.cxx) which method is called for the OpCode. Add-In functions are separate, but that's how you can find any built-in function's implementation. Niklas Hope this is helpful. Otherwise we will have to wait for Niklas' response. Wojciech Gryc wrote: Thank you all for the responses! I've put together a small document (temporary link: http://www.utsc.utoronto.ca/~04grycwo/overview.pdf) that outlines some thoughts in terms of how I see this going, and a few potential strategies. Here's a quick summary: 1. Creating an R package that communicates directly with OpenOffice and allows the passing of commands back and forth. 2. Doing the above with a TCP/IP connection instead. 3. Macros - sub-optimal in my opinion, but can be done. I downloaded and started playing with OO source code. You're right in saying the documentation isn't the greatest, though I can see why: there's a lot here. I think I'm getting the hang of it all, but just had some questions: 1. Using the wiki, I learned how to modify current functions, and exploring the code shows me where add-ins are placed and how they look. I was wondering, however, where do function names get stored? Again, I see the interpX.cxx but those function names are not the same as the ones I call from Calc -- how does Calc know what to call? I guess what I am trying to get at is, how can I add functions to Calc through the source code? All the tutorials I've found are for add-ins. 2. From your perspectives, should this be considered an add-in or directly coded into the sc folder? Is there any other area of the source code I should be working in? 3. Any thoughts on the TCP/IP versus package-to-OO communication mentioned above? I think it might be a bit beyond the scope of the summer project, but I'd be happy to try to tackle it if there's interest. I just finished my last exam for this school year on Friday at 4 pm, so I'll be working on this pretty much full-time now. You can expect to hear a lot more compared to what you've been hearing so far. :) Thank you, Wojciech - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [sc-dev] R + Calc Update
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. :) Regarding the bias in the macro (missing = 0) -- yes, this is a problem but the goal was more to show this R/Calc connection is doable. There's a few other bugs as far as I can tell, like if you were to choose two non-adjacent columns. That being said, I won't develop this further until I find other ways of doing this. I don't really want the work to depend on a TCP/IP connection. That being said, I met with Louis Suarez-Potts from OO today (he lives in Toronto and we met through my university) and one thing he brought up was that if a TCP/IP connection is used it could be possible to have people separate the computers running the data analysis from those actually using Calc. I CC'ed him here in case I missed the main point, so please feel free to correct me! I thought this is an interesting idea, and wanted to pass it by you. I can have a R/Calc integration use a local server but build an option into it that will allow the tool to connect to another server to do the analysis. I know other projects (e.g. http://nwb.slis.indiana.edu/) that plan to do something similar. Any thoughts? Thanks, Wojciech On 4/20/07, Leonard Mada [EMAIL PROTECTED] wrote: Nice to see the work started. There is still a lot to do, but at least the work has started and it is possible to connect Calc to R. Wojciech Gryc wrote: ... Now, I also wanted to let everyone know that using RServe, I built a Java-based macro that gets R to calculate the correlation between two columns in Calc. The direct link to an outline of the work, source code, etc. is: http://www.11-55.org/ooblog/?p=6 Already spotted an error: I believe that 'xs.getCellByPosition(sCol, sRow + i).getValue()' returns '0' for *Missing Values*, instead of NA! This falsifies results where values are missing. [I am NOT sure that this is the culprit, BUT *missing values* are indeed handled incorrectly.] I pointed this out, because IF getValue() indeed interprets missing values as 0, we have a problem with this method. The purpose here was to get a proof-of-concept working, and this is by no means an outline of how the final product will look. ... There is still much work to do. Macros could be OK as well, but it is probably better to take the RExcel approach, to store the R commands as strings in the table and have a context menu entry 'Run R Command' and 'Get R Results', and also some Calc menus for useful R functions. Yet, a nice work for the beginning. Regards, Leonard - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Five Minutes to Midnight: Youth on human rights and current affairs http://www.fiveminutestomidnight.org/
Re: [sc-dev] R + Calc Update
Hi Niklas, could you please explain what this code does? { ScMatValType nType = GetDoubleOrStringFromMatrix( fVal, rString); bIsString = (nType != SC_MATVAL_VALUE); } My thinking is: - it gets content of current table cell - IF content is a numerical value, fVal is set - IF content is string, rString is set and nType is set to SC_MATVAL_VALUE Am I correct with this interpretation? And, what happens IF the cell is empty? Thanks. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [sc-dev] R + Calc Update
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. My suggestion would be to find a framework that is not GPL'ed and is released under a license that allows us to ship it. But if you still need to release your component under GPL for whatever reason, we have two options: 1) Keep your component separate from the main product (OO.o), but that's a suboptimal solution IMHO. 2) Contribute your code to the R project, and make that a part of R distribution. But then, I'd rather you contribute code to the OO.o project, :-) so this solution is still suboptimal from OO.o project's point of view. I don't really want the work to depend on a TCP/IP connection. Why not? :-) Given the licensing constraint we have with this task, relying on TCP/IP connection as a way to have a non-GPL software to connect to a GPL-ed software sounds pretty attractive to me. Let's recap. I have already listed two possible ways to use a GPL'ed software from a non-GPL'ed software without violating the license: 1) Load the library at run-time, using dlopen (or equivalent). This avoids the need to dynamically link your program with the R library, which would require your program to be released under GPL (not good). 2) Execute the R program inside a forked process and pass a custom script you crafted to R, then parse and interpret the output. The drawback of this approach is parsing the output could be very labor-intensive, and prone to error. Now there is a third way: 3) Modify R to accept TCP/IP connection, and write a component on OO.o side to connect to R via TCP/IP. In this scenario, your modification to R will be released under GPL with the R project, and your OO.o component will be released under LGPL. Oh, wait. I just thought of another one. :-) 4) Convince the R developers to release the R library under LGPL, then we can ship it with OO.o. The drawback of this approach is that if the R core developers are not interested, all bets are off. That being said, I met with Louis Suarez-Potts from OO today (he lives in Toronto and we met through my university) and one thing he brought up was that if a TCP/IP connection is used it could be possible to have people separate the computers running the data analysis from those actually using Calc. I CC'ed him here in case I missed the main point, so please feel free to correct me! Yup. Interesting thought. Kohei - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [sc-dev] R + Calc Update
Nice to see the work started. There is still a lot to do, but at least the work has started and it is possible to connect Calc to R. Wojciech Gryc wrote: ... Now, I also wanted to let everyone know that using RServe, I built a Java-based macro that gets R to calculate the correlation between two columns in Calc. The direct link to an outline of the work, source code, etc. is: http://www.11-55.org/ooblog/?p=6 Already spotted an error: I believe that 'xs.getCellByPosition(sCol, sRow + i).getValue()' returns '0' for *Missing Values*, instead of NA! This falsifies results where values are missing. [I am NOT sure that this is the culprit, BUT *missing values* are indeed handled incorrectly.] I pointed this out, because IF getValue() indeed interprets missing values as 0, we have a problem with this method. The purpose here was to get a proof-of-concept working, and this is by no means an outline of how the final product will look. ... There is still much work to do. Macros could be OK as well, but it is probably better to take the RExcel approach, to store the R commands as strings in the table and have a context menu entry 'Run R Command' and 'Get R Results', and also some Calc menus for useful R functions. Yet, a nice work for the beginning. Regards, Leonard - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]