Articles by R on Alan Yeung

Trying out timeplyr

December 2, 2023 | R on Alan Yeung

The timeplyr R package, created by my colleague Nick, was accepted on CRAN in October 2023. A direct quote from the CRAN page is that it provides a set of fast tidy functions for wrangling, completing and summarising date and date-time data. It look...
[Read more...]

Grouped Sequences in dplyr Part 2

November 6, 2023 | R on Alan Yeung

I just wrote a post about grouped sequences in dplyr and following that, I’ve been made aware of another couple of solutions to this problem (credit John Mackintosh). The solution involves using the consecutive_id() function, available in dplyr sinc... [Read more...]

Grouped Sequences in dplyr

November 4, 2023 | R on Alan Yeung

For a piece of work I had to calculate the number of matches that a team plays away from home in a row, which we will call days_on_the_road. I was not sure how to do this with dplyr but it’s basically a ‘grouped sequence’. For this ... [Read more...]

A couple of case_when() tricks

October 8, 2023 | R on Alan Yeung

Combining case_when() and across() If you want to use case_when() and across() different variables, then here is an example that can do this with the help of the get() and cur_column() functions. library(tidyverse) iris_df [Read more...]

Summarising Dates with Missing Values

October 1, 2023 | R on Alan Yeung

This blog post is just a note that when you try to do a grouped summary of a date variable but some groups have all missing values, it will return Inf. This means that the summary will not show up as an NA and this can cause issues in analysis ... [Read more...]

Rafa 21 Grand Slams and gganimate

February 12, 2022 | R on Alan Yeung

I’ve been a Nadal fan for a long time – right back to the days of the pirate-pants so yeah, really a long time. In all this time, Rafa has never been ahead in the grand slam race vs his biggest rivals… but that finally changed after the 2022 Austra... [Read more...]

Filtering with string statements in dplyr

May 12, 2020 | R on Alan Yeung

A question came up recently at work about how to use a filter statement entered as a complete string variable inside dplyr’s filter() function – for example dplyr::filter(my_data, "var1 == 'a'"). There does not seem to be much out there on this and I was not sure how ... [Read more...]

Updating packages on a drat repo

May 2, 2020 | R on Alan Yeung

This is just a small note (mainly for myself but hopefully may be of some use to a few others!) to remind of how to update a package on a drat repo. Create the source file for the package you want to host on the drat repo using devtools::build(). ... [Read more...]

Updating packages on a drat repo

May 2, 2020 | R on Alan Yeung

This is just a small note (mainly for myself but hopefully may be of some use to a few others!) to remind of how to update a package on a drat repo. Create the source file for the package you want to host on the drat repo using devtools::build(). ... [Read more...]

Scotland’s Most Popular Babynames

January 24, 2020 | R on Alan Yeung

Downloading the data Shiny App I recently saw this great post on Nathan Yau’s FlowingData website which guesses a person’s name based on what the name starts with. It also needs you to select a gender and a decade for when you were born before it can guess. ... [Read more...]

Scotland’s Most Popular Babynames

January 24, 2020 | R on Alan Yeung

Downloading the data Shiny App I recently saw this great post on Nathan Yau’s FlowingData website which guesses a person’s name based on what the name starts with. It also needs you to select a gender and a decade for when you were born before it can guess. ... [Read more...]

Trying the ckanr Package

November 11, 2019 | R on Alan Yeung

How resources are grouped in CKAN Initialising ckanr and exploring groups of resources Connect to CKAN with dplyr and download from one resource Downloading all resources from a dataset In previous blog posts (Hacking dbplyr for CKAN, Getting Open Data into R from CKAN) I have been exploring how to ...
[Read more...]

Trying the ckanr Package

November 11, 2019 | R on Alan Yeung

How resources are grouped in CKAN Initialising ckanr and exploring groups of resources Connect to CKAN with dplyr and download from one resource Downloading all resources from a dataset In previous blog posts (Hacking dbplyr for CKAN, Getting Open Data into R from CKAN) I have been exploring how to ...
[Read more...]

objectremover RStudio Addin

August 11, 2019 | R on Alan Yeung

A Learning Exercise Workflow I created my first ever R package and got it released onto CRAN in March 2019. It’s taken me a while to get round to actually writing about this which tells me that despite many years of trying to overcome procrast... [Read more...]

objectremover RStudio Addin

August 11, 2019 | R on Alan Yeung

A Learning Exercise Workflow I created my first ever R package and got it released onto CRAN in March 2019. It’s taken me a while to get round to actually writing about this which tells me that despite many years of trying to overcome procrast... [Read more...]

Hacking dbplyr for CKAN

July 6, 2019 | R on Alan Yeung

Aim Create a dummy database Test dbplyr’s SQL translation Modify dbplyr’s SQL translation Testing the dbplyr hack Concluding notes At the end of my first post on CKAN discussing how to use the CKAN API to extract data from the NHS open data platform directly into R, I ... [Read more...]

Hacking dbplyr for CKAN

July 6, 2019 | R on Alan Yeung

Aim Create a dummy database Test dbplyr’s SQL translation Modify dbplyr’s SQL translation Testing the dbplyr hack Concluding notes At the end of my first post on CKAN discussing how to use the CKAN API to extract data from the NHS open data platform directly into R, I ... [Read more...]

Getting Open Data into R from CKAN

June 4, 2019 | R on Alan Yeung

Preamble Open Data in Scotland Querying CKAN Querying with Custom JSON Querying with SQL Conclusions and Further Ideas Preamble I’ve got lots of rough pieces of R code written as I’ve been exploring/testing various things in the past. A lot of this is currently stored in a ... [Read more...]

Getting Open Data into R from CKAN

June 4, 2019 | R on Alan Yeung

Preamble Open Data in Scotland Querying CKAN Querying with Custom JSON Querying with SQL Conclusions and Further Ideas Preamble I’ve got lots of rough pieces of R code written as I’ve been exploring/testing various things in the past. A lot of this is currently stored in a ... [Read more...]
1 2

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)