Blog Archives

Building a base dplyr with primitives

February 15, 2020
By

Introduction In one of my latest posts, I discussed the idea of turning base R’s get and set operators ([, [[, [

Read more »

Primitive Functions List

February 1, 2020
By

Ever wondered which R functions are actually passed to internal C code? Well, wonder no more as it turns out there is an unexported named list within the methods package providing instructions for turning builtin and special functions into generic functions. Wrapping this list with names() gives us the list of all R functions which wrap calls to .Primitive(). names(methods:::.BasicFunsList) #...

Read more »

Get and Set List Elements with magrittr

February 1, 2020
By

Introduction Did you know that the magrittr pipe, %__%, can be used for more than just data.frames and tibbles? In this blog post, we look at how we can create get and set functions for list elements. Getting List Elements First, let’s create a simple list. z1 %. How can we do that? Well we can pipe our list into a . which...

Read more »

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 »

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)