- Three-Way Operator in R
Is there a merit for a three-way operator in R?
Background In C++20 revision added “spaceship operator”, which is defined as follows:
(a <=> b) < 0 # if lhs < rhs (a <=> b) > 0 # if lhs > rhs (a <=> b) == 0 # if lhs and rhs are equal/equivalent. R implementation The behaviour can be achieved in R in multiple ways. A one straightforward approach would involve making use of the ifelse statement
- Installing Hortonworks Sanbox Deployment (HDP) on Docker Mac
Background The post covers installation of Hortonworks Sandbox Deployment (HDP) on Mac using Docker.
Installation Docker Before installing docker let’s check for the existing installation.
which -a docker # /usr/local/bin/docker Assuming that the line above did not produce results we can install docker with use of homebrew. To install homebrew:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" we can the progress with installing docker
brew install docker HDP The HDP can be installed with the provided scrip.
- Interactivly Loading Shiny Modules
TL;DR If you want to see the implemented solution, please refer to: GitHub repo.
Context Shiny is a widely popular web application framework for a R. In simple tearms it enables any R programmer to develop and deploy web application. This application could be simple - an interactive document consiting of a few charts and tables or a c complex “behemoth” with multiple functionalities enabling end-users to run models, query external data, generate exportable reports and sophisticated visuals.
- Amusing way to get user input windows in R
In an unlikely scenario that beautiful Shiny apps do not meet your analytical requirements and developing a full-blown user interface. in RGtk2 may seem to be a little too much, there is a third, often overlooked solution, - package svDialogs by Philippe Grosjean. The package in a convenient way enables user to create various interface gadgets. For example the code:
require(svDialogs) # Let's keep some data in one place user_figure <- svDialogs::dlg_input() would result in the following window being presented to the user:
- ASCII charts in R
In Stata it is possible to use function plot in order to get a simple scatter plot in Stata console. As of Stata eight, plot is no longer supported but remains a useful tool for quickly exploring relationships between variables. Using plot on the auto data provides the following results:
Stata textual plot
Now the question is: can we achieve the same level of convenience in R? Of course.
- Managing rows in the ggplot legend
After developing the Shiny App sourcing live labour market data from NOMIS. I wanted to accommodate a convenient way of managing rows in the legend. In particular, I wanted to account for the situation where end-user may select a number of geographies that will only conveniently fit into two or more rows. After transposing the data to long format, guessing the number of elements in the legend is relatively simple as it will correspond to the number of unique geographies passed via the subset command.