# Refactor

<img src=“refactoring.png”, width = “400”, height = “600” style=“float: left;margin-right: 20px;margin-top: 0px;margin-bottom:0px;">

This is quite exciting: since Nathan (this is his very interesting blog) has arrived to UCL a couple of months ago, we’ve started to work on quite a few of very interesting projects — including a major “refactoring” of the code for BCEA. I’m obviously very attached to BCEA — it’s basically my first R package and one I’ve spent lots of time thinking about and then working on. And I think it’s usually very helpful to practitioners and I always push people around to try and get them to use it.

BUT: it’s more than fair to say that when I was thinking about the structure and then coding up the functions, I was not the best programmer — not that I am today, but I think I know a lot more what I’m doing now than I did a few years ago. Also, I do think that R has changed somewhat in the past few years, with the advent of the Rstudio crowd and then the various ideas they brought forward, including tidyverse and rmarkdown.

Anyway, Nathan has taken it upon himself (among quite a few other things…) to look at the code and essentially modernise and streamline all the functions and functionalities. Interestingly, at the user end, you probably don’t see many changes — the functions work as they did originally (ie the call is the same). But the underlying package is now in places a bit quicker and generally speaking a lot neater. We’ve also worked in response to a couple of requests for changes in the code — the changes are nearly ready and will feature our next major update.

For now, we’re working on the dev branch; you can still use the resulting updated package (which we’ve labelled as version 2.4), using the code

pkgs <- c("MASS","Rtools","devtools")
install.packages(pkgs,repos=repos,dependencies = "Depends")


before installing the package using devtools:

devtools::install_github("giabaio/BCEA",ref="dev")


under MS Windows. Under Linux or MacOS, it is sufficient to install the package via devtools:

install.packages("devtools")
devtools:install_github("giabaio/BCEA",ref="dev")


(notice the option ref="dev" in the call to devtools:install_github to point to the relevant branch of the GitHub repository).

We’ll keep testing the changes and possibly bring in a couple of new features — particularly around the graphical representation of the outputs. And will post more as we have news!