Publications by rstats-tips.net

Converting Lists of Lists of Lists to Data.Frames (or Tibbles)

06.02.2021

I’m working on an R-package to access the data of a web service. So I have to handle large data I get back from an API call. The result is encoded in JSON-format which itself results in a large list of lists (of lists). But I want to convert these lists of lists into a data.frame or tibble. Sounds easy …. Here are the caveats I came across. S...

2404 sym R (5865 sym/52 pcs) 26 tbl

Simple Prediction in SARS-CoV-2 Shiny App

27.02.2021

I made another small update to my SARS-CoV-2 Shiny App. As the discussion in Germany about whether to open schools and shops starts again I was wondering how I could visualize a simple prediction of future infections. So I did the following simple approach: Take the lowest and highest 7-day R-value of the last 7 days. Then use these two R-values ...

1218 sym 2 img

Splitting Linear Models

02.04.2021

Last Thursday I watched Wolfgang Viechtbauer’s stream on Twitch. Wolfgang spoke about linear regression. (If you’re interested in the results: Wolfgang lists the R-code he wrote during the stream at https://www.wvbauer.com/doku.php/live_streams.) During the stream we had an example with one categorical and one numeric predictor and we built a...

3333 sym R (6751 sym/74 pcs) 4 img 37 tbl

Sorting German Numbers in DT datatable

22.04.2021

DT::datatable() is a great way to show interactive tables in RMarkdown documents. (Unfortunately it’s a little bit tricky to use them with blogdown in combination with some hugo themes. But that’s another story.) The user can sort any column as he wants to. But it’s an English tool. Numbers are formated in the American or English way: As de...

1683 sym R (1309 sym/11 pcs) 5 tbl

Accessing PIWIK PRO from R

14.05.2021

The main tool for tracking the action on a website is Google Analytics. But more and more websites switch to other tools such as Matomo or PIWIK PRO due to GDPR. My employer decided to switch to PIWIK PRO, too. So I was looking for a way to access the data PIWIK PRO was collecting to process it with R. When we used Google Analytics as web analyti...

2575 sym R (905 sym/10 pcs) 5 tbl

Using R 4.1.0 and R 4.0.5 on MacOS using RSwitch

21.05.2021

Lately R version 4.1.0 was released on CRAN (see https://cran.r-project.org). The MacOS version was one day late. But yesterday it was released, too. So I wanted to test the new version without being able to go back. “No problem”, I thought “I’m already using RSwitch”. RSwitch is a tiny Mac program which allows you to switch between ins...

2355 sym R (158 sym/2 pcs) 1 tbl

Simple tricks for Debugging Pipes (within magrittr, base R or ggplot2)

05.06.2021

You know it, I’m sure: You are developing a data transformation using lots of pipes. Then you need to remove one or more lines. You do this using comments. So far so good. But if it’s the last line you want to remove a simple comment will produce an error because of the trailing pipe symbol at the end of the second to last line. Here’s a so...

1498 sym R (4429 sym/18 pcs) 2 img 9 tbl

Adding lines or other geoms to a ggplot by calling a custom function

10.07.2021

Sometimes you generate lots of ggplots of a similar kind, e.g. visualizations of different timeseries. Then you want to highlight some dates where something special had happened and you want to show that the value you are plotting changed at these dates. So it would be nice if we can refactor these geom_vline or geom_hline calls into one single f...

1187 sym R (1215 sym/12 pcs) 6 img 6 tbl

Working with tree-based hierarchies using data.tree

30.07.2021

Lately I tried to visualize an hierarchy with Tableau Desktop. The problem was that the hierarchy had a variable depth because it was tree-based. Each row had an id and a parent_id. Normally hierarchies in Tableau are defined by pulling some fields together, such as product category, product group and product id. Handling tree-based hierarchies s...

2751 sym R (10051 sym/32 pcs) 16 tbl

Update to piwikproR: fetching DateTimes via API

16.10.2021

Last weekend I fixed some issues with my R-package piwikproR The new version 0.3.1 is now available at CRAN So let’s have a look at the changes: The main change is that you now can fetch DateTime values from PIWIK PRO when you are using the API-endpoints /sessions or /events. The previous version just removed the time component and converted th...

1140 sym