Thursday 1 December 2022

statistical language, my R-se...

Until this day I knew nothing about R. But I got to work a bit on a program that reads some spreadsheets, turns these to csv's, and then R enters the scene for a moment and then the stuff is being saved to some database. Whatever the goal is, I can't see much science inside, and when I see calculating logarithms of heights and depths, my inner Statler&Waldorf immediately entere that pure-scientist-anti-engineer mode.

The main R script had some import calls with the absurdly looking argument like comment.char="Ł". "Ł" is a Polish letter, sometimes jokingly called L/2\pi; people familiar with symbols from quantum world will get the joke; its pronouciation is very simple to the way you pronounce the "w" in "way" or "wait" or "wiggle".

The script is apparently written by some French guys or girls who pretended to care about English-reading users ("Non-convenient input file!"). It seemed to fail even to load some "MASS" library - it continued to show the same error even after some creative hiding of the first input file - renaming files is as creative as I can get being that mad... I tried the most naive --verbose option and got it finally to work after replacing the "Ł" with a pile of hash that I got from a dealer. The keycode that gives me access to free hash is obtained by pressing shift-3.

The --verbose mode gives some details about where the problem occurs, but doesn't even care about showing the goddamn line number in a script - I had to look up the line using the error or exception message. And I had to shift the args[] index so that it points exactly at the i/o filenames in the args list as previously, since I introduced "--verbose" as an extra argument; the authors didn't care about argument parsing, validation etc. 

For some reason, the 3.6.-something version of R did its job just ok - with the exotic "Ł". Current version (4.2.2) that I had to install failed. Sounds like a joke to me. 

<IndianSoftwarePseudoTutorialMode State="On">Conclusion:
So, in this tutorial . . .
</IndianSoftwarePseudoTutorialMode>

Now I know something about R. It's way worse than python, which seems groundbreaking and a bit sad to me - I've had so much great time suffering with .py and finally getting stuff working. This led to mass production of anti-py rants. R seems at least one lever higher. Its syntax is super-obscure and even if it does its job well, I just want to keep away from it. It's one of them un-languages; a bunch of bored whoever come to a place where every decent library is super well tested and decides to wrap these in something new and make it more or less popular. Well, if people want to suffer with it, it's their business.

Perhaps it's possible to write cleanly in R. Error messages without line numbers seems like a very cunning enforcement for clean coding - as long as you have lots of small modules in separate files, that's probably fine. Well, in my case there are two files, > 1100 lines total. 

I'm not against science, being an ex-pre-scientist myself, but I'm very frequently against coding done by scientists, esp. when it gets outside scientific world where it should belong. It's sort of sad how much time and effort is being wasted on writing these ugly codes. But I recall how much scientists appreciate the free time aspect of it all. And grant-hunting of course. We all like money, don't we? Hopefully the younger generation would change something here. Not that I hope that the quality of the codes' outcome, interpretation and publications is going to drastically increase.

No comments:

Post a Comment