Monthly Archives: April 2018

Computer addictions, “No Computer Day” and idle brain

Years ago my computer addiction included playing cards (I think it was called Solitaire), browsing websites (news during the day, porn at night), later also Facebook and some other social apps. Now I found myself addicted to R. However stupid it may sound, it seems to be true. By addiction I mean: it is not easy to stop when you need to do something really important. All those things before (cards, news, porn, Facebook) are understandable, and I bet I am not the only one who fights with that. But R? Come on. I thought that I had a perfect therapy last year after the semester of teaching R three hours per week (and countless hours preparing the class and checking assignments). Right, I was sick of seeing R for a while, but not for long. It was around that time I also found Shiny, an interactive option how to play R, and coded my first Shiny app. It’s nice – you click, something changes, click again, changes again, keep clicking, improving, adding new ideas, making new apps… and addiction is cooked, no escape.

Some time ago I came with an idea to introduce “No Computer Day.” A day, when you should not touch the computer, at all. Obviously, it cannot be during the working day (unless I go to the field), so the weekend is a hot candidate. It would be cheating to set the No Computer Day on the day you go out of the house – so as so you would not touch it. No, just set up the ordinary Sunday, when you have a plan to relax, but ordinarily, you would still end up sitting in front of the computer (I may do something useful today) and keep clicking (doing nothing useful at all). It’s similar to “a week without alcohol” (all bottles in the house need to be locked somewhere since the late evening feeling of “just one beer” is surprisingly strong). Just leave your computer switched off (not just sleeping – you may touch the mouse, and it will wake up, with blinking screen luring your attention). You will see how difficult is it to resist (ok, I will just check emails, what if something important is there!), but how rewarding it could get (clean the house, read the book, fix what should have been fixed long time ago, go for a walk, sleep – add your own “no-computer” items).

Sometimes I wonder: how did the life of scientist (let’s say a teacher at university doing also research, or simply a full-time scientist in academia) looked like before the computers were standing on her/his desk? Come to office, make a coffee, check the mails, do paperwork (ok, this sounds almost the same as now). And then? Take a pencil, read a paper and write a notes, take a typewriter, write a short piece of manuscript, put it away, take a pencil again, make a phone call, take a typewriter, go for lunch, meet a colleague for coffee, pencil, paper, typewriter, … Anyway, the most important currency of scientists are the ideas, and those are not born in the computer, but in the head, often while doing things entirely not related to work or when the brain is simply idle. What if sitting the whole day in front of blinking computer makes the time for these idle moments rare, and thus the productivity goes down? Ok, by productivity I don’t mean the number of published papers (although I should, since that’s precisely how my productivity is measured by school/grant agency/colleague). By productivity I mean coming up with some interesting idea. What if switching off the computer (or even temporarily moving the computer somewhere out of the sight) in fact increases this kind of productivity?

Ok, but I still need to boil these ideas down to a paper…

Unconstrained ordinations in vegan: an online Shiny app

The R package “vegan”, written and maintained by Jari Oksanen, Gavin Simpson and others, contains the whole set of functions needed for unconstrained ordination (and many other things) in R. I also experimented with other packages (“labdsv” by Dave Roberts or “ade4” by Stephane Dray et al.), but “vegan” is unbeatable when it comes to ordinations. One a little annoying thing in “vegan” is the naming convention of various ordination functions. It’s relatively easy to get used to that PCA (principal component analysis) and CA (correspondence analysis), respectively, are calculated by “rda” and “cca”, respectively, which, if one also supplies environmental variables, also calculate constrained versions (RDA aka redundancy analysis and CCA aka canonical correspondence analysis). DCA (detrended correspondence analysis) is calculated by “decorana”, which also makes sense, if you know the history of the method and the fact that first program written by Mark Hill in Fortran to calculate DCA was called exactly in this way (and in fact the “decorana” function in R is based on the original Fortran code ported into R by Jari). Somewhat harder is to remember that NMDS (non-metric multidimensional scaling) is calculated by a function called “metaMDS”, and the definite killer for me is PCoA (principal coordinate analysis), calculated by “cmdscale”. When you are teaching these to students, it may get a bit frustrating, so some handouts come handy. That’s partly why I got this idea: an interactive online tool, which would allow using few example community ecology dataset, analyse them by a set of standard ordination methods, draw resulting ordination diagram, print summary output, and mainly – show also the R code which was used to do all that. The result is here, welcome to click through!

Previously I used Shiny apps to play with visualisation of random drift, and I got quite hooked on the concept of a dynamic website with R running behind. In the case of this project, it got more complex, and I spent the whole day learning various Shiny hacks (e.g. how to modify dynamically also the clickable menu at the left panel). Although the result is far from perfect (and perhaps will stay like that for a while), it’s functional. You may choose one of the datasets (short description and the link to the website with details will appear), then choose one of six ordination methods, transform or not the community data, and decide what to display in the ordination diagram. The figure above shows the PCA on a simulated community dataset structured by one long gradient, and a lovely horse-shoe artefact which PCA chronically produces on datasets with many zeros.

Don’t get me wrong – this is not an attempt to provide an online, clickable alternative interface to “vegan”, I have no intention to do something like this. But I think that Shiny apps are a great teaching aid and visualisation tool. If you have a new R package and want to show how it works, a small Shiny example may be much better than a long online tutorial (at least as an appetiser with the aim to hook users actually to try the package).

Welcome to play, and thanks for any feedback!