Projects

randomsearch

R-package: Versatile randomsearch for optimization with parallelization in mind.

geo2smoof

R-package: Convert altitude data to mathematical functions.

Dortmunder R Kurse

Tutor for the R-Courses in Dortmund.

rsmac

A small R-package to interface the SMAC optimizer.

mlrMBO

Co-author and maintainer mlrMBO - the comprehensive toolbox for model-based optimization in R.

mlrHyperopt

A R-package that enables easy, effortless hyper parameter optimization for mlr.

mlr

Co-author of mlr - the R-package for machine learning.

mlr-blog

Maintainer and co-author of the mlr-blog.

Blog

Last Value

Have you calculated something in R that took some time but you forgot to save the result? Fear no more. .Last.value always stores the last result.

runif(5)
## [1] 0.61736122 0.02023587 0.28592244 0.60450306 0.84834418
mean(.Last.value)
## [1] 0.4752734
Read More

Is true really true?

An often forgotten R-function while developing: isTRUE() and it’s brother isFALSE(). Have you found yourself in the situation that you had to write

if (!is.null(foo$bar) && foo$bar == "awesome") {}

Much shorter is the following:

if (isTRUE(foo$bar == "awesome")) {}
Read More

Keep data.frame a data.frame

When writing R functions always remind yourself to think about if it can happen that you accidentally just select one column of a data.frame. This will result in vector which might not be what you expect in the following code. One good practice is to always use drop=FALSE when you intend to get a data.frame and use the [[]] notation if you expect a vector.

df = data.frame(a = 1:3, b = letters[1:3])
cols = c("a")

Lets assume cols is a vector which only sometimes has the length one, then we would do the following:

df[, cols, drop=FALSE]
##   a
## 1 1
## 2 2
## 3 3

And to purposefully select a vector:

df[[cols[1]]]
## [1] 1 2 3
Read More

Plot correctly with `par`

Sometimes you have to work with base::plot and to combine multiple plots the solution is e.g. par(mfrow=c(1,2), ...). Unfortunately using par can mess up all your future plots in the active R session. This is one handy trick to get back to the default settings for plotting:

op = par(mfrow = c(1, 2))
plot(runif(100), runif(100))
plot(runif(100), runif(100))

plot of chunk unnamed-chunk-1

par(op)
plot(runif(100), runif(100))

plot of chunk unnamed-chunk-1

Read More