Posts

Showing posts from May, 2020

The xml2relational package: Transforming NoSQL to relational data

Usually it is easier to work with data when you have them in a tabular, relational format. Often enough however, we only get the data in an object-oriented, NoSQL data format like XML or JSON. So there is a need to transform NoSQL data to something that is easier to work with. This is where my new package  xml2relational  comes into play.  What xml2relational does xml2relational is designed to convert XML documents with nested object hierarchies into a set of R dataframes. These dataframes represent the different tables in a relational data model and are connected amongst each other by foreign keys. Essentially, xml2relational flattens an object-oriented data structure into a relational data structure. Once the relational structure is created (and that is basically a list of dataframes representing the different tables) you can export both the data model (as SQL CREATE statements) and the data (either as SQL INSERT statements or as CSV files) to get the data easily into a rel

A switch-case construct for the R language

Introduction In contrast to many other programming languages, R has no real native switch-case statement. It does provide the primitive switch() function; but switch()  is actually made to select elements from a list based on their name or index position. It cannot (at least not without awkward workarounds) be used to build conditions with more complex comparison values. Also, when fed with a numeric expression, it interprets the expression as an index and selects the element from the list at this index position. This is not useful when you want to test an expression against another numeric expression/value. It would be good to have an efficient way of testing multiple, similar conditions, including conditions that are more complex in their comparison values or result in numeric values. At the same time nested if-else constructs should be avoided because they make the code less clear and readable. The switchcase package provides a solution by offering a true switch-case constr

New article on R package development (in German)

Recently, I published an article in the German online magazine ' Informatik Aktuell ' about R package development. It is a pragmatic introduction to contributing your own packages to R and works with a simple example package that is developed from A to Z in the article. The code of this example package ( tempconvertr ) can also be found in a GitHub repo at  https://github.com/jsugarelli/tempconvertr . Read the full article here (in German):  https://www.informatik-aktuell.de/entwicklung/programmiersprachen/r-packages-entwickeln.html .