Posts List

Random thoughts on SQL and R

The post below is a collection of useful (but kind of random) thoughts about R and SQL. It should serve more like a starting point, rather than exhaustive discussion of the presented topics. Note that it mostly describes SQLite - many concepts will be similar for different databases, but they might not be identical. You’ve been warned! R, SQL, dbplyr and ORM When we are talking about accessing SQL from a programming language, it is good to know a little bit about an ORM concept.

Active learning - part 1

I just started exploring the ‘active learning’ topic. It’s a very handy tool when the number of data points to build a model is limited and labelling new points is costly. It allows to determine which points should be labelled next to bring the most gain in model performance. In this post I will cover some of my small experiments in this area. Caution! If you’re interested in ready-to-use tools for active learning, this post might not be for you - I don’t cover any framework here.

Deploying Shiny Apps

Shiny apps are a very convenient way of sharing your work with others, especially with non-technical co-workers. The best way is to deploy your app somewhere on the internet (or intranet), so the user won’t need to install R, packages, and other stuff, let alone the need for easy updates. There’re a few ways to host your applications, and all of them comes with some pros and cons: Shinyapps The most natural solution is to put your app on the shinyapps.

Dynamic modules in shiny - Part II

In the previous post about shiny modules, I described how to dynamically add new modules, or even select a module type from a few possibilities. The main problem was that the new module is added inside an observer function, so we cannot directly get the returned value of the new modules. However, we can solve this problem quite easily using reactiveValues. We just add a parameter to the module’s server function in which we will send the reactive value used to communicate between the main application and the module.

DepthProc hit 20k downloads.

My first package published on CRAN - DepthProc recently hit 20k downloads. library(cranlogs) library(ggplot2) downloads <- cran_downloads("DepthProc", from = "2014-08-21", to = "2018-06-10") ggplot(downloads) + geom_line(aes(x = date, y = cumsum(count))) + ylab("Downloads") + xlab("Date") + theme_bw() + ggtitle("DepthProc", "Download stats") There are some jumps on the line. I wondered if they all occurred just after the package release (old users updates to the new versions). Here’s some code to check this.

Caching function's result based on file modification time in R.

I had some time to look at some of my started, yet never finished projects. I found something which served me very well for some time, and it was quite useful. In my one project, I was working with a lot of large logs files. In the beginning, I was loading the whole file into R memory, and then I was processing it using stringi package and other tools. This was not the best solution.

StarSpace in R

I enjoyed work with Facebook’s fastText ( library and its R’s wrapper fastrtext ( However, I want to spend some more time with StarSpace library (also Facebook’s library for NLP). Unfortunately, there’s no R package for StarSpace! It’s quite surprising because I there are thousands of packages. Nevertheless, this one is missing. In the end, I decided to write my wrapper - I had some problems with compilation because of dozens of compiler flags which must be set before compilation.

dragulaR with renderUI

Quite recently someone asked about if it’s possible to use my dragulaR ( package with renderUI. My first thought was that this might be quite hard. I knew that insertUI is not a problem because you can set ‘immediate = TRUE’ parameter, and just after that use ‘js$refreshDragulaR(“dragula”)’ to refresh the dragula container. However, with insertUI you cannot simply use refreshDragulaR, because it must be called when all the elements in the uiOutput are ready, and this is not so easy to do so.

Data Science - News - 2018-02-28

Some interesting Data Science stuff found between 2018-02-01 and 2018-02-28. - (by J.J. Allaire from Rstudio) - Machine Learning with R and TensorFlow - a video introduction to Deep Learning in R. #deeplearning #rstats #tensorflow #datascience - (by James Le) - a collection of some basic ML algorithms for newbies. Pictures in the article are pretty good. #datascience #ml - (by Matt Dancho) - predicting customer churn using deep learning in R.

RNews - 2018-01-31

Some interesting Data Science stuff found between 2018-01-16 and 2018-01-31. - (by Rafael Irizarry) package dslab containing datasets for teaching data science. install.packages(“dslabs”) #CopyAndInstall #applyrds #rstats #datascience - a general purpose #NLP library from @fb_research. For now, it works only from a command line. However, it’s easy to build and use from command line. #FacebookResearch #applyrds - Facebook open sources Detectron, a platform for object detection running on the top of Caffe2.