Announcing naijR v.0.1.2

It is a pleasure to announce that today, naijR version 0.1.2 was published on the Comprehensive R Archive Network (CRAN). This update has some bug fixes as well as general fine-tuning, and features mostly internally-facing changes that should improve user experience as well as the overall utility of the package. If you’re just learning about naijR, please read both Part 1 and Part 2 of my blog series introducing the package.

To install this stable version of the package, run the following line of code in the R console:


NB: CRAN takes about 48-72 hours to release binaries of new or updated packages, so be sure to install and build the source package if  necessary. For that, I refer you to Professor Karl Broman’s simple guide here.


Some of the updates effected have impacted package functionality as follows:

The ‘FCT’ abbreviation

Nigeria’s Federal Capital Territory is quite commonly abbreviated as ‘FCT’ in regular use. This is not easily recognised in the earlier version of the package


is_state("Federal Capital Territory")
## [1] TRUE
## [1] FALSE

In this new version, this was fixed and is_state("FCT") currently evaluates to TRUE.


div id=”modified-validation-for-functional-programming” class=”section level2″>

Modified input validation

Previously, an input validation check for the is_state  function stops execution and produces an error, when the object supplied is not a character vector. For example, when called with the inbuilt objects letters and pi, the function tells us that the former does not contain any States and that the latter is not even qualified for the check since it is of type numeric.

## [1] FALSE
## Error: A character vector was expected

It turns out that although it works as expected, the construct is not very useful for testing for States if one is using functionals like lapply or purrr::map on, say, data frames. Operations that allow the application of a function along a vector are ubiquitous in applied data science, but is_state was found to be too eager;  any column in a data frame that is not of type character is not checked and operation terminated at that point. Using the inbuilt mtcars data set,

sapply(mtcars, is_state)
## Error: A character vector was expected

It is preferable in such constructs, for the predicate (in this case is_state) to traverse the object and return a boolean. With the changes made in the function’s logic in v0.1.2, the result of the same line of code is

sapply(mtcars, is_state)
##   mpg   cyl  disp    hp  drat    wt  qsec    vs    am  gear  carb 

giving us a more useful and informative result. All the columns are now checked and we can clearly see that none of them contains data representing the Nigerian States.


These are the most obvious changes that were made in this patched version of naijR. Work on the package is still ongoing, with many new features in the offing. Again, feedback or contributions to the code or documentation are welcome and can be provided via the package’s GitHub repository.


Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s