Skip to content

Instantly share code, notes, and snippets.

View johnmackintosh's full-sized avatar

John MacKintosh johnmackintosh

View GitHub Profile
@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 / 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 / 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 / link.txt
Created March 28, 2020 16:10
UK qv maps extension free
@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 / 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 / nhsr_datasets.R
Created August 15, 2019 22:56
trial run with NHSRdatasets package and runcharter
library(NHSRdatasets) # install from github for latest dataset
library(runcharter)
library(data.table)
library(magrittr)
# Load
data("ae_attendances")
DT <- setDT(ae_attendances)
@johnmackintosh
johnmackintosh / keybase.md
Created February 21, 2019 21:16
Keybase verification

Keybase proof

I hereby claim:

  • I am johnmackintosh on github.
  • I am johnmackintosh (https://keybase.io/johnmackintosh) on keybase.
  • I have a public key ASDQIp7YliqUjDZBfWl37te22cunTdTKJ2nKeYaEyF9Wdgo

To claim this, I am signing this object:

@johnmackintosh
johnmackintosh / midtable-predictions.R
Created August 11, 2018 23:15
obtainin combinations of possible football results
#Setup current fixtures and points per outcome
library(dplyr)
library(purrr)
library(tidyr)
library(ggplot2)
library(ggalt)
library(ggrepel)
library(ggExtra)
library(stringr)
@johnmackintosh
johnmackintosh / succinct row of dots dplyr.r
Created June 3, 2018 21:50
even shorter version of row of dots dplyr
plot_data <- data %>%
mutate(Movement15 = lubridate::floor_date(MovementDateTime,"15 minutes")) %>%
group_by(IN_OUT, Movement_Type,Staging_Post,Movement15) %>%
mutate(counter = if_else(IN_OUT == 'IN',1,-1),
Movement_15_SEQNO = cumsum(counter)) %>%
ungroup()