Publications by rstats-tips.net
forcats::fct_lump_n() with weights “overall”
Sometimes I want to summarize some categories which don’t have much impact on my analysis. So the best way to do this is using some of the forcats::fct_lump*() functions. But I often struggle to find the way using the weights to order the categories. That’s because the main use case of fct_lump() is a vector of a factor containing several value...
1728 sym R (3723 sym/24 pcs) 12 tbl
JSON, NULL values and as_tibble
When working with data provided by common APIs you will almost always get in contact with JSON formatted data. Using R’s rjson::fromJSON will transform JSON to R’s lists. So far so good. Converting those lists to tibble using tibble::as_tibble will fail when the JSON (and therefor the list) contains NULL values. So you havve to replace them bef...
1433 sym R (2262 sym/20 pcs) 10 tbl
Query BigQuery throws error: Error in strsplit(name, “.”, fixed = TRUE) : non-character argument
Lately I tried to query BigQuery using bigrquery. Unfortunately I got an error: Error in strsplit(name, ".", fixed = TRUE) : non-character argument Updating to the latest packages on CRAN doesn’t solve the problem. So I had to dig deeper. The solution was installing the latest version of bigrquery from Github (which is 1.4.2.9000) using devtools:...
779 sym
How to use nflfastR with Google BigQuery?
Lately I wanted to play around with nflfastR. That’s a great package giving you access to NFL’s play-by-play data since 1999. It let’s you download all the data and store it in several different databases. Unfortunately I ran into trouble when I tried to import the data to Google’s BigQuery. Two problems I’ve identified to problems. Th...
3273 sym R (17448 sym/4 pcs) 2 tbl
Where does bigrquery store credential-tokens on a Mac?
This blogpost is mainly a reminder for myself where I can delete this information. But what’s all about? Recently I installed bigrquery and ran queries against Google’s BigQuery cloud-database before I had installed gcloud (and did the authorization as described at https://docs.getdbt.com/reference/warehouse-setups/bigquery-setup#local-oauth-...
1236 sym
pkgdown and GDPR – How to host a pkgdown site in Germany
pkgdown is a great tool for generating a website with documentation for an R package. Unfortunately, pkgdown uses CDNs (content delivery networks) like Cloudflare to embed often used JavaScript libraries into the generated website. Also, fonts are included in such a way. That’s a good idea when these files are cached over websites away. But in ...
1827 sym R (55 sym/2 pcs) 1 tbl
Strange warning after loading own package
After upgrading my local R version to version 4.2.1 I always got an annoying warning after loading my own package. This only occurred using RStudio. 1 2 3 Warning message: In length(steps) == 0 || nchar(steps) == 0 : 'length(x) = 2 > 1' in coercion to 'logical(1)' “Okay, that’s something new in R 4.2.0”, I thought and found https://st...
1093 sym R (118 sym/2 pcs) 1 tbl
Iterating over the rows of a data.frame with purrr — Part 2
A year ago I already wrote an article how to iterate over the rows of a data.frame. Now I’ve run into another special case. Last year we used pmap_dfr() to pass each element of a row as single parameter to our custom function. But what should you do if your function accepts a data.frame (or list) as one single parameter? The function … But le...
1422 sym R (2262 sym/16 pcs) 8 tbl
Shiny-App to Explore SARS-CoV-2 in Germany
I’ve visualized the Covid-19 data I’ve got from Pavel Mayer in different ways ( see https://www.rstats-tips.net/2020/08/16/additional-visualization-of-covid-19-development-in-germany/ or https://www.rstats-tips.net/2020/08/09/visualization-of-corona-incidence-in-germany-per-county/ ) But I always wanted to make it more interactive. So I decid...
1921 sym 12 img
Updated Shiny App
Today I’ve updated my Shiny App I wrote about a few days ago. I’m using now Flexdashboard to embed a shiny app into an Rmarkdown-File. Using Flexdashboard caused a little trouble when using observeEvent(). But currently the apps works, but throws a warning regarding observeEvent() in respect to plotly. 1 The 'plotly_click' event tied a sour...
1506 sym R (212 sym/2 pcs) 4 img 1 tbl