Skip to content

Instantly share code, notes, and snippets.

View johnmackintosh's full-sized avatar

John MacKintosh johnmackintosh

View GitHub Profile
@johnmackintosh
johnmackintosh / nhsr_conference_2019_links.md
Last active November 5, 2019 13:19
links to stuff highlighted on twitter at the NHSR Conference 2019
@johnmackintosh
johnmackintosh / not_in.R
Created January 22, 2020 15:28
simple 'not in' function
# there are a few ways of doing this.. here's one
`%notin%` = function(x, y) !(x %in% y)
@johnmackintosh
johnmackintosh / link.txt
Created March 28, 2020 16:10
UK qv maps extension free
@johnmackintosh
johnmackintosh / tidy-data-guides. txt
Created April 24, 2020 14:15
Tidy data guides for non tidy, non data people
https://guides.library.upenn.edu/datamgmt/spreadsheet
https://www.tandfonline.com/doi/full/10.1080/00031305.2017.1375989
https://about.dataclassroom.com/blog/2019/10/23/keep-your-data-tidy
@johnmackintosh
johnmackintosh / awesome-sql.txt
Created May 4, 2020 22:24
awesome-sql-article
https://jaxenter.com/10-sql-tricks-that-you-didnt-think-were-possible-125934.html
@johnmackintosh
johnmackintosh / sqlFetchData.R
Created June 2, 2020 13:53
wrapper function for DBI /SQL Server that actually works - via https://stackoverflow.com/a/61073561/5175413
sqlFetchData <- function(connection, database, schema, table, nobs = 'All') {
#'wrap function to fetch data from SQL Server
#
#@ connection: an established odbc connection
#@ database: database name
#@ schema: a schema under the main database
#@ table: the name of the data table to be fetched.
#@ nobs: number of observation to be fetched. Either 'All' or an integer number.
# The default value is 'All'. It also supports the input of 'all', 'ALL' and
@johnmackintosh
johnmackintosh / link.txt
Created June 14, 2020 23:14
Great package/ OOP guide
@johnmackintosh
johnmackintosh / automate blog years.txt
Created January 1, 2021 12:29
Update the year in the copyright notice of blog post automatically
<script>document.write(new Date().getFullYear())</script>
or
<script>new Date().getFullYear()>2005&&document.write("-"+new Date().getFullYear());</script>
library(data.table)
library(gsheet)
library(ggplot2)
link <- 'https://docs.google.com/spreadsheets/d/1GYv4573GnJa-C21NYeDj-OhFSTwrK0SnQNF2IQFqa50/edit#gid=0'
import <- gsheet2text(link, format = 'tsv')
DT <- fread(import)
DT[, Date := as.IDate(DT$Date, format = "%d/%m/%Y")]
library(here)
library(data.table)
library(stringr)
setwd(here("2021-02"))
# read in and process
DT <- fread('Input.csv')