Articles by HighlandR

new programming with data.table

February 4, 2024 | HighlandR

The newest version of data.table has hit CRAN, and there are lots of great new features. Among them, a %notin% function, a new let function that can be used instead of := ( I wasn’t too fussed about this originally but have tried it a few ti... [Read more...]

more .I in data.table

February 2, 2024 | HighlandR

Following on from my last post, here is a bit more about the use of .I in data.table. Scenario : you want to obtain either the first, or last row, from a set of rows that belong to a particular group. For example, for a patient admitted to ... [Read more...]

.I in data.table

January 2, 2024 | HighlandR

In this post I’m using a small extract from the SIMD2020 dataset to figure out what the special operator .I does. Files and code are on github if you’re interested # files and code : https://github.com/johnmackintosh/DT_dot_I library(data.t... [Read more...]

non-equi joins in data.table

December 21, 2023 | HighlandR

I have been toying with some of the advent of code challenges (I am way behind though!). For day 5, I had to create a function, and I’m writing this up, because it’s an example of a non-equi join between two tables. In this particular sitat... [Read more...]

Achieve your target

May 20, 2023 | HighlandR

Last week I had to talk my colleagues through the architecture of an R project that we’ve been working on for a while. This is a large project, as we make our first moves into Reproducible Analystic Pipelines, and makes heavy use of the {tar... [Read more...]

Pivoting in tidyr and data.table

February 19, 2023 | HighlandR

We all need to pivot data at some point, so these are just some notes for my own benefit really, because gather and spread are no longer in favour within tidyr. NB - this post has been updated with collapsible sections to show/hide the data ... [Read more...]

Pivoting in tidyr and data.table

February 17, 2023 | HighlandR

We all need to pivot data at some point, so these are just some notes for my own benefit really, because gather and spread are no longer in favour within tidyr. I tended to only ever need gather, and nearly always relied on the same key and ... [Read more...]

Making headlines

January 25, 2023 | HighlandR

In my current mammoth work project, I’m generating many plots. The titles are very descriptive (they tell you what the plot is about), but they are not really telling a story. That’s simply because there are so many on the production line. ...
[Read more...]

On target

December 13, 2022 | HighlandR

Here are some notes on getting started with {targets}. The project I am working on involves several different reports, each at least 30 pages, and each with about 20 plots and 20 tables per document. As well as a myriad of functions, I had ...
[Read more...]

modifying columns in datatable with lapply

August 29, 2022 | HighlandR

Here’s a quick example of needing to make some updates to an existing column in a data.table. For reasons I don’t want to get into (involving MS Word :/) I had to change a couple of columns from factor to character, and swap out the ampersan... [Read more...]

Exploring your database with shiny

June 13, 2022 | HighlandR

Several of my recent blog posts have been focussed on using {purrr} and {glue} to programatically query a database. This is something I’d been wanting to achieve for some time, but my efforts got put on hold when COVID-19 came along. The ge... [Read more...]

Separate SQL

February 7, 2022 | HighlandR

I did a tweet earlier which was slightly less nonsense than usual. Shocker, I know. I don’t think the idea of having SQL files being kept separate, rather than having a SQL query either embedded or called within an R script, is that controve...
[Read more...]

Inverness street maps

February 2, 2022 | HighlandR

Taras Kaduk produced a beautiful street map here and I decided to try it, but for Inverness. Initially I followed his code very faithfully, and produced a nice plot, but upon uploading the image to GitHub, and seeing it rendered against a da...
[Read more...]
1 2 3 7