Publications by HighlandR

Some data.table tips

21.03.2021

I’ve been using data.table quite a lot in my spare time, and I want to make a few notes of some things I’ve learned along the way. I would say I’m no longer a beginner, not yet an expert, but getting there.. As noted in a previous post, I’ve been doing the PreppinData challenges, or at least I was – things have fallen a bit by the waysi...

4011 sym R (3145 sym/8 pcs)

Introducing popthemes

25.03.2021

Back once again with the block rocking themes! Yes, having produced a set of R colour palettes based on Metallica album covers, and then another set of palettes based (loosely) on classic rock album covers, I’ve decided to complete the set with{popthemes} One problem with {rockthemes} is that I got carried away, and I have way more palettes tha...

4631 sym R (226 sym/11 pcs) 24 img

Introducing popthemes

28.03.2021

Back once again with the block rocking themes! Yes, having produced a set of R colour palettes based on Metallica album covers, and then another set of palettes based (loosely) on classic rock album covers, I’ve decided to complete the set with {popthemes} One problem with {rockthemes} is that I got carried away, and I have way more palettes th...

4665 sym R (226 sym/11 pcs) 24 img

Cutting down code in dplyr and data.table

08.08.2021

After a very long , R free hiatus (I don’t recommend it) I’m back on the R train, destination unknown. I had a bit of spare time last night, and remembered I had not done a PreppinData challenge for a while. In fact, the last one I did was week 8, and they are now on week 31 – the exact details of the challenge can been seen below. Preppin...

5257 sym R (2919 sym/8 pcs)

Cutting down code in dplyr and data.table

11.08.2021

After a very long , R free hiatus (I don’t recommend it) I’m back on the R train, destination unknown. I had a bit of spare time last night, and remembered I had not done a PreppinData challenge for a while. In fact, the last one I did was week 8, and they are now on week 31 – the exact details of the challenge can been seen below. Preppin...

5257 sym R (2919 sym/8 pcs)

Well Well Well my Excel

11.08.2021

Importing multiple excel files (not sheets, but files) and flattening into one data frame / tibble / data.table should be straightforward – shouldn’t it? How many ways can there be? What are the pros and cons of each? I’ve made three copies of an excel file from a PreppinData challenge. For this, I just want to import the first sheet from e...

2827 sym R (8042 sym/12 pcs)

Well Well Well my Excel

12.08.2021

Importing multiple excel files (not sheets, but files) and flattening into one data frame / tibble / data.table should be straightforward – shouldn’t it? How many ways can there be? What are the pros and cons of each? I’ve made three copies of an excel file from a PreppinData challenge. For this, I just want to import the first sheet from e...

2933 sym R (8042 sym/12 pcs)

Calculating hotel occupancy with R

16.09.2021

I saw a question on reddit today which can be answered using {patientcounter} The asker wants to know how to work out how many folk are in a hotel, at any given time, based on check in and check out dates. Here’s the setup: check_in_date <- c('2010-01-01', '2010-01-02' ,'2010-01-01', '2010-01-08', '2010-01-08', '2010-01-15',...

1033 sym R (2205 sym/3 pcs)

fwf without the faff

04.10.2021

Fixed width files? What are those? Well, imagine your entire dataframe/ tibble/ data.table is in a single column. That’s it, over 200 columns, in one. Each row is a very long string. Sounds fun right? Ideally, there would be delimiters ( you know, a few friendly commas between columns) to help you figure out where each new column starts. Or yo...

2733 sym R (131 sym/2 pcs) 4 img

Pass parameter to SQL Server DATEADD function using R

19.10.2021

I wanted to try and create some parameters in my flexdashboard script, so I could extract data from our warehouse over a flexible date range. In SQL Server, I’d create a variable and reference it like this: DECLARE @ndays int SET @ndays = -7 SELECT cols, that, I , want FROM [server].[schema].[table1] t1 LEFT JOIN [server].[schema].[table2] t2 O...

3872 sym R (1660 sym/4 pcs) 2 img