Skip to content

Instantly share code, notes, and snippets.

View kamermanpr's full-sized avatar

Peter Kamerman kamermanpr

View GitHub Profile
@kamermanpr
kamermanpr / open_prescribing.R
Created June 29, 2020 12:05
Downloading gabapentinoid prescription data for England from openprescribing.net
#-- Load packages --#
library(readr)
#-- OpenPrescribing API details --#
# API details can be found here: https://openprescribing.net/api/
# Drug codes can be obtained here: https://openprescribing.net/analyse/
#-- Download pregabalin data --#
## Total items prescribed
total_pregabalin <- read_csv('https://openprescribing.net/api/1.0/spending/?code=0408010AE&format=csv')
@kamermanpr
kamermanpr / compounding.R
Created January 15, 2019 14:02
Illustrating compound growth using absolute investment value, change from initial investment, and percentage change from initial investment.
############################################################
# #
# The effect of starting investment amount #
# on returns realised. The magic of compounding #
# #
############################################################
# Load packages
library(ggplot2)
@kamermanpr
kamermanpr / rstudio_ami_guide.md
Created September 18, 2018 09:34 — forked from jaeddy/rstudio_ami_guide.md
steps for creating and configuring a new AMI with RStudio Server

Building a new RStudio Server AMI

The steps below can be followed to create a new AMI for use with Amazon EC2 instances that includes the latest versions of R, RStudio, and RStudio Server. The idea is inspired by the work of Louis Aslett, who creates and hosts his own public AMIs for RStudio. My own goal was to create an AMI with RStudio v1.0.0 or higher, such that I could use the recent R Notebooks feature. However, the instructions should generally apply for whenever you might be impatient accessing the latest version of R-related software on AWS (via an interactive browser interface...).

Getting started

  1. Create a new EC2 instance with the latest Ubuntu AMI (should be fine to do with Spot); based on Louis Aslett's AMI, I opted to include a general purpose SSD EBS volume with 10GB of storage space
  2. SSH into the instance

Downloading/installing RStudio Server

@kamermanpr
kamermanpr / install-xcodeCLT-homebrew-git.md
Last active November 9, 2023 17:50
Install Xcode Command Line Tools, Homebrew, and Git on macOS

Install Xcode command line tools, Homebrew, and Git on macOS

Install the following apps on your mac running macOS:

  1. (standalone) Xcode Command Line Tools
  2. Homebrew
  3. Git

Modified from: https://www.moncefbelyamani.com

@kamermanpr
kamermanpr / confint_rlmerMod.R
Last active January 25, 2018 07:24
Wald confidence interval of robustlmm::rlmer beta coefficients
# Wald confidence interval of robustlmm::rlmer beta coefficients
# Adapted from code provided Ben Bolker on StackExchange: https://stats.stackexchange.com/questions/233800/how-can-i-get-confidence-intervals-for-fixed-effects-using-the-rlmer-function-r
confint.rlmerMod <- function(object, level = 0.95) {
# Extract beta coefficients
beta <- fixef(object)
@kamermanpr
kamermanpr / maxOSExtra_installs.sh
Last active June 22, 2017 14:57
Install xcode tools, homebrew, and git
#!/bin/bash
# I use this script after a clean install of macOS to re-install homebrew, git, and xcode tools.
## Install xcode tools
xcode-select --install
## Install homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
@kamermanpr
kamermanpr / proxyscript.sh
Last active April 14, 2021 06:00
Bash script to toggle proxy server settings for the terminal, git, and R based on network location setting (OSX)
#!/bin/bash
# By Peter Kamerman (peter.kamerman@gmail.com)
##########
# FUNCTION
##########
# Script to toggle the proxy configurations of the terminal, git, and R
# for use behind a proxy server (e.g., at work) and no proxy (e.g., home).
########################
# DISCLAIMER and LICENSE
########################
@kamermanpr
kamermanpr / RArticleNetwork.R
Created January 2, 2016 14:41 — forked from mbarnkob/RArticleNetwork.R
R code for generating a network of referring articles from pubmed. More info here: http://mikebarnkob.dk/2015/generating-an-article-network-using-rentrez-and-igraph-in-r/
#Article Network ver 2
#============================
# This program will scrape all citing articles surrounding one main article and
# create: 1) a list of most cited articles, 2) lists of main authors, 3) network of articles
# Mike Barnkob, December 28th 2015.
# www.mikebarnkob.dk
#Background and references
#1. https://cran.r-project.org/web/packages/rentrez/vignettes/rentrez_tutorial.html#advanced-counting