Calling R from Visual Basic

4/02/2005

This post is an utterly miscellaneous brain dump:

  • Last week I got pharyngitis and am still taking antibiotics, side effects situation that I really dislike.
  • Yes, geriatrician I am a doctor in the real sense of the word, despite what the physician that prescribed antibiotics thinks.
  • Last Saturday I got one of the worst haircuts ever—at least that I can remember—at Just Cuts. Yes, it is my fault for first choosing to go to a such dubious place: avoid it if you can. Nevertheless, every time I passed outside Paul’s barber shop he was busy. Today I went to his place with my tail between my legs and beg him to have it fixed. We had a laugh, had it fixed and he made me promise not to repeat my sin.
  • Cooked a beautiful marinated octopus pasta last night. Looking forward to eat the left overs at lunch time.
  • Last Christmas I got a few vouchers from ‘Music without Frontiers’, one of the few music stores in Hobart where one can find something outside the ‘top 20′. I went back to my old listening habits, and got:
  • Andrew told me that last Saturday was Captain Beefheart’s birthday. I did not know who CB was so I will have to borrow some of his art.

It is hard for me to get interested in current mainstream music: no challenges, one can guess what is coming so easily that tends to be a big yawn. That’s all folks.

High productivity of matrix languages like Matlab and S+ or their Open Source siblings Scilab and R are a joy to use. I wrote programs in Matlab during my PhD and I can still go back to the code and perfectly understand what is going on there. Now I am writing a lot of S+ and R code where a few lines manage to perform complex operations.

A good programmer can certainly produce better performing (on terms of speed and memory requirements) program using a low(ish) level language like C, viagra 60mg
C++ or website
I am not such a good programmer and it would take me ages to do some of my work if I needed to write things using those languages. Most of the time execution speed and memory usage are not the limiting factors, and speed of development rules.

I am extremely happy now using R and playing with the idea to use it as a statistics server for a few small applications. Omega Hat seems to be a very valuable resource for all things ‘connecting R to other software’.

A long lived quicky

Around 2001 I wrote a ‘temporary quicky’ to compare new Eucalyptus samples to already identified haplotypes. I did that in a few lines of VBA in MS Excel, which was the software used as a repository for these haplotypes. At the time I suggested ‘this is a quick fix and it would be a good idea to develop a proper data base’, and suggested a structure allowing for user roles, web access, etc. I was told that ‘this is not a priority’ and ‘we are happy with the spreadsheet’.

Yesterday I was having lunch with the owner of this spreadsheet, who told me that a.- it is still being used after four years! and b.- they were having some problems because they changed a bit the structure for storing the haplotypes. I offered help to fix the problem but I was told that ‘one of my students will try to fix it, because the problem has to be something very simple’.

I thought that the comment was a bit dismissive and if it was so easy why haven’t they fixed it in over a month? Granted, the code is extremely simple but they do not have any programming experience whatsoever.

VBA is a fine scripting language, which allows people to write short and useful programs. However, I would question that in this case an Excel spreadsheet is the best option for storing molecular genetics information.

A better generic language

In general, scripting languages (like Matlab or R) feel like a better fit for me. Python, my all time favourite language, feels much more productive than any other language I have ever used. In addition, combining Python with the Numerical Python library produces an excellent all purpose/matrix programming language. This can be used for prototyping and—if one is happy with performance—transformed into a standalone program using a utility like py2exe.

Our telephone service for the last three years has been provided by Ecomtel (a small company), information pills
although the physical infrastructure belongs to Telstra (the largest telecommunications provider in Australia). Initially we were very happy with Ecomtel’s services, rx
they had low charges and their service seemed to be very responsive. The icing in the cake for me was their reliance on Open Source Software (e.g., prostate Linux), which made easier for them to be very competitive in price—particularly for international calls.

This year we logged an issue with Ecomtel, because our low speed of connection to internet (maximum of 14.4 Kbps, pathetic, isn’t it?). After some investigation, it was established that the problem was in the quality of our line—that belongs to Telstra, which happens to be a paired gain system rather than an individual copper line. We pointed out to Ecomtel that according to the TIO the minimum speed of connection to internet should be 19.2 Kbps:

The Internet Assistance Program was set up as a joint venture between Telstra Corporation and the Federal Government to ensure a minimum transmission speed of at least 19.2 kilobits per second to all users of its fixed network. Subsequently, it was decided that a minimum speed of 19.2 kilobits per second would become a condition of Telstra’s licence agreement. While this condition is not binding on other network carriers (where Telstra does not provide the underlying infrastructure), the TIO views this as an industry benchmark and expects that regardless of which network a customer is connected to, the standard telephone line provided should be capable of a minimum transmission speed of 19.2 kilobits per second.

The fact is that physically it is not possible to achieve 19.2 Kbps with a paired gain connection. Telstra and Ecomtel say that we should pay for a new telephone connection (cost AU$209) to change to a copper line. Our position is that i- we were never offered the option between types of line when connected in the first place and ii- the current line does not meet the condition for Telstra’s licence agreement anyway. By the way, the ‘new connection’ only involves unplugging our line from one connector and plugging it back in a connector sitting next to the original one.

We have been discussing the issue with Ecomtel for over a month, and they have not been very responsive during this time. We will now take this issue to the TIO and see if we can get a new connection without the extra cost. During this process, we changed from loyal (telling our friends to switch to Ecomtel) to dissatisfied (writing this post) customers. A real business lesson in how to alienate your customers.

Checking the server logs I have discovered that many people that arrive at my posts on calling VB from R are, dermatologist
in fact, looking for the reverse. I have never done any programming calling R from VB; however, while I was looking for COM clients for R I also found information on COM servers. OmegaHat lists RDCOMServer as a package that exports S (or R) objects as COM objects in Windows. It provides examples on using VB, Python and Perl to call R code.

Another option is Thomas Baier’s R(D)COM Server, which is provided with examples in the same languages used by RDCOM Server.

Filed in programming, statistics

No comments yet.

Write a comment: