Rewriting R before GRD
Got very frustrated at the end of the day yesterday—I was trying to write up the code to get the stacked, 3D plot of characters related to linking mechanisms working. The code started to get very messy, because I needed to use the culled version of the matrix to construct the basic morphospace plot by PCO, but I needed access to the full matrix to show all of the relevant characters—because some of them fell victim to the culling process. But since I’ve been referring to the matrix as “m” throughout the code, and variously loading the full or the culled matrix into that variable as needed, this was getting ugly when I needed access to both. I was wasting time and getting lost going back and forth in my code, trying to execute bits and fragments of it to do what I wanted to do.
In short, I realized that it was no longer feasible to store this code as a long script broken into various sections dealing with the various aspects of analysis. The analysis will be so much easier and cleaner if I just repackage this into functions that I can call from a much shorter script, or directly from the command line.
So, this meant a bit of extra unanticipated work, and I was a little slow getting started with this in the morning. I think it’s just a little daunting, because the code I’ve written for the analysis now tallies up to an impressive 28 pages, so it’s a fair bit of effort. But I just don’t trust myself to be able to add another 7 or 8 analysis steps (as I outlined yesterday) without completely derailing myself in the chaos of going back-and-forth in a completely linear, procedural script. Things will get screwed up unless I tidy this up.
Spent most of the day working on this, and got about half way done. Didn’t get to my stated goal (as of yesterday) of spending the afternoon thinking/reading/writing… Bit by bit. I’ll get to it, tomorrow.
- previous:
- “There’s a Real Contribution Here”
- next:
- Missed Mislabeling Mistake


Beau
December 2, 2011 @ 6:10 am
I must say I’m really enjoying reading these posts – more progress in a shorter period of time than I recall in a while! I know it’s fruit of a lot of hard work – the posts give the impression it’s a smooth forward progression, and I know it’s not always like that – so kudos to you on keeping the engagement levels up and getting ‘r done.
Don’t underestimate the benefit of refactoring. In the spirit of clean code, it can reduce the incidence of bugs, make the code a damn sight easier to maintain, and allow for future extensibility (never say never…) So this is definitely a worthwhile effort.
Hopefully Friday goes well for you!
B