Category Archives: Tips & Tricks

How to Check if a Date is Within a List of Intervals in R

Intro I'm currently involved in a research project called EFFECT. EFFECT is a multicentre, cluster-randomised, placebo-controlled cross-over trial evaluating antiseptic body wash of patients on intensive care units (ICU). The trial is to test whether daily antiseptic body wash reduces … Continue reading

Posted in Tips & Tricks | Tagged , , | Leave a comment

Drawing a Fish Curve using R and ggplot2

Intro Recently, I wondered whether there is a way to draw a fish shape using a mathematical function. Since I did not find a ready-made R function, I tried to write the function by myself. The equations, I've used for … Continue reading

Posted in Tips & Tricks, Visualizing Data | Tagged , | Leave a comment

How to order factors by level frequency and level name

Intro Quite frequently, factor variables are ordered by level frequency. However, factor levels having only a few observations are sometimes collapsed into one level usually named “others”. Since this level is usually not of particular interest, it may be a … Continue reading

Posted in Tips & Tricks, Visualizing Data | Tagged | 2 Comments

Postleitzahlen mit führender Null richtig formatieren

Intro Importiert man Postleitzahlen aus anderen Datenformaten (z.B. Excel, Access) in R, ist es nicht selten, dass Postleitzahlen programmintern tatsächlich auch als Zahlen abgespeichert werden. Wie ein Blick auf einen im Internet frei verfügbaren Datensatz zeigt, kann dies zu folgendem … Continue reading

Posted in Tips & Tricks | Tagged , | 2 Comments

R Markdown: How to place two tables side by side using ‘knitr’ and ‘kableExtra’

Intro When I was recently writing some report using R Markdown, I wanted to place two rather small tables side by side. Since I usually use the kable()-function of the knitr package and the kableExtra package to print tables, I … Continue reading

Posted in Tips & Tricks | Tagged , | 3 Comments

How to Assign Variable Labels in R

Intro Defining variable labels is a useful way to describe and document datasets. Unlike SPSS, which makes it very easy to define variable labels using the data editor, base R doesn't provide any function to define variable labels (as far … Continue reading

Posted in Data Management, Fav R Packages, Tips & Tricks | Tagged | Leave a comment

How to fix problems after updating to R 3.4.1 on Linux Mint 18.1 / Ubuntu 16.04

The Problem After updating R to version 3.4.1 (“Single Candle”) on Linux Mint 18.1, RStudio could neither find my installed R packages nor was it possible to install R packages into some other directory. The Solution Fortunately, this problem could … Continue reading

Posted in Tips & Tricks | Tagged , | Leave a comment