R

A 19-post collection

Simulating Distribution Equivalence

By Conor Neilson |  Sep 13, 2024  | r, simulation
Been a long time since I did any simulation in R! Today I was presented with a nice opportunity too. I received a message from my brother today saying “sqrt(rand()) gives you the same probabilities as max(rand(), rand()) assuming rand() returns a number between 0 and 1.” I was immediately intrigued as this didn’t make intuitive sense to me. However, no need for intuition! This is a data-driven blog, so lets look at this in a data-driven way.
Continue Reading...

Converting miles to kilometers using the fibonacci sequence

By Conor Neilson |  Sep 6, 2024  | r
Lets do a quick exploration into some interesting properties of the fibonacci sequence! Converting distances between miles and kilometers is something we’ve all done a bunch of times (maybe?). For as long as I can remember I’ve held the rough rule in my head of multiplying miles by 1.6 to get the rough amount of kilometers. This is perfectly acceptable. In 99% of day to day, this will be all you need.
Continue Reading...

Two new data packages

By Conor Neilson |  Oct 23, 2021  | r
I’ve recently released two new data packages for R - read on to learn more about them. I’ve spent some time recently building a couple of new data packages. I was inspired by coming across a dataset by tech magazine ‘The Hustle’. They collated a dataset called “The Hustle’s iPhone vs. Android Survey” which surveys peoples phone preferences. In analysing this data I found it had a field that reported the city the respondent was from.
Continue Reading...

Integrating blogdown and pkgdown

By Conor Neilson |  Sep 4, 2021  | blogdown, r, tutorial
Make your pkgdown websites be part of your blogdown website. Context I have websites set up using both blogdown and pkgdown. The reason for using both is they solve very different problems. For instance I have My main personal website, built with blogdown, and hosted by Netlify Individual websites for R packages, built with pkgdown, and hosted on Github Pages This is a case where it’s appropriate to be using both.
Continue Reading...

What I have in my .Rprofile

By Conor Neilson |  Aug 22, 2021  | r
The .Rprofile file is an extremely useful piece of R. For those who haven’t encountered .Rprofile before, it is a text file where you can put R code - this code is then source’d everytime R starts up. Thus, it makes a great place to set options you use frequently, create functions, or just to wish yourself a good morning. In this post I plan to run through the things I like to put in my .
Continue Reading...

A quieter scrobbler

By Conor Neilson |  Aug 15, 2021  | package-development, r
I just released a tiny update to scrobbler. Something you may have noticed is that scrobbler can sometimes be rather loud when you are using it. When downloading scrobbles it likes to print your username and api key periodically. This is both annoying and (in the case of the api key) rather unsafe. The new version of scrobbler will still print its progress indicators, but will no longer emit your authentication details.
Continue Reading...

Current dev project - spotty

By Conor Neilson |  Aug 15, 2021  | package-development, r
I started playing around with a new package today which I’ve titled spotty. spotty’s goal is to be a minimal wrapper around the spotify API. It intends to only do a small number of things but do them well. There is of course the very well done package spotifyr by Charlie Thompson. spotty is not indended to compete with this package at all, and will not come anywhere near the breadth of features offered by spotifyr
Continue Reading...

Generated plots are now working by default?

By Conor Neilson |  Aug 15, 2021  | r
In a previous post I described how plots generated via R code weren’t showing in my posts. The fix I ultimately found was to set a particular knitr chunk. I didn’t really understand it, but it seemed to work. This no longer seems to be the case. I tried generating some plots today to test, and they work out of the box now. Check the code below - there are no other knitr chunks in this document.
Continue Reading...

Scheduling scrobbler (properly this time)

By Conor Neilson |  Aug 14, 2021  | r, tutorial
I finally learn how Github Secrets work! My previous mistake In a previous post, I showed an example of how to use Github Actions to schedule scrobbler to run automatically and save the downloaded data into your github repo. This was a bit janky because you had to hardcode your API details into the script, and therefore it had to be a private repo in order to avoid leaking your details.
Continue Reading...

Scheduling scrobbler to run automatically

By R package build |  May 20, 2021  | r, tutorial
Using github to automatically schedule, run, and store dataframes of your scrobbles in a repository. One of the biggest issues you can run into when trying to analyse your scrobble data is waiting for it all to download when running download_scrobbles(). While the addition of update_scrobbles() partially helps this, it still relies on you having a relatively recent source of scrobbles available in a dataset. The idea behind this post is to setup a github repo where you can store scrobbled datasets.
Continue Reading...