Blog Archives

Selecting the max value from each group, a case study: dplyr and sparklyr

September 22, 2019
By

Introduction In my last post we looked at how to slice a data.table by group to obtain the rows for which a particular column in that group is at its maximum value using the excellent data.table package. In this post, we will be taking a look at how to perform this task using dplyr and sparklyr. dplyr First, let’s take a look...

Read more »

Selecting the max value from each group, a case study: data.table

September 14, 2019
By

Introduction In my last post we looked at how to slice a data.frame by group to obtain the rows for which a particular column in that group is at its maximum value sing base R. In this post, we will be taking a look at how to perform this task using data.table. data.table Solution(s) For this exercise we will be using datasets::mtcars...

Read more »

Posts

September 14, 2019
By

. (You can report issue about the content on this page here) Want to share your content on R-bloggers? click here if you have a blog, or here if you don't. To leave a comment for the author, please follow the link and comment on their...

Read more »

Selecting the max value from each group, a case study: base R

September 14, 2019
By

Introduction Let’s say we wish to group some data by a variable, then for each group we wish to find the row of the maximum value of another variable, and then finally extract the entire row. This is a fairly common task and in fact I’ve had to do this exact data exploration technique on several occasions in the last...

Read more »

Including Optional Functionality from Other Packages in Your Code

September 5, 2019
By

Introduction Let’s say you want to write a function with optional functionality which is dependent on the installation of a package that your colleague may not have installed. For example, let’s say you want to have an option to return a data.table (or a tibble) instead of a data.frame, but in this case you don’t want to force your function’s...

Read more »

No visible binding for global variable

August 18, 2019
By

Recently I have been working on a very large legacy project which utilises the excellent data.table package throughout. What this has resulted in is an R CMD check containing literally thousands of NOTEs similar to the following: ❯ checking R code for possible problems ... NOTE my_fn: no visible binding for global variable ‘mpg’ There are several reasons why you...

Read more »

Extending sparklyr: Data Types

March 8, 2018
By

TL;DR sparklyr maps R data types and data storage types to Scala, but it doesn’t handle all data storage types. This blog post discusses how to generate Scala data storage types from the R side, that are not generated by sparklyr. You can do this by using the sparklyr::invoke_new function to generate the objects you want in Java or Scala,...

Read more »

Project Euler in R

February 28, 2018
By

Project Euler This is just a short blog post to raise some awareness to some fun programming and mathematical challenges I recently came across, hosted on Project Euler. The idea behind Project Euler is to provide abstract programming challenges for p...

Read more »

Accessing Private Methods from an R6 Class

August 13, 2017
By

I recently wrote a package to solve the Twitter Waterflow Problem using an R6 class. You can view the package here and read about how I approached the problem here. In this blog post, I want to highlight how you can access private members of an R6 clas...

Read more »

The Twitter Waterflow Problem

August 9, 2017
By
The Twitter Waterflow Problem

Introduction I was recently introduced to the Twitter Waterflow Problem and I decided it was interesting enough to try and complete the challenge in R. Consider the following picture: This plot shows a series of walls and empty valleys. We can represent this picture by an array of integers, where the value at each index is the height of the wall....

Read more »

Search R-bloggers

Sponsors

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)