Skip to content

Instantly share code, notes, and snippets.

View tessam30's full-sized avatar
😎
back to data janitor mode

tessam30

😎
back to data janitor mode
View GitHub Profile
@tessam30
tessam30 / snippets_rstudio
Last active July 3, 2023 18:09
R studio snippets
snippet lib
library(${1:package})
snippet req
require(${1:package})
snippet src
source("${1:file.R}")
snippet ret
library(gt)
library(gtExtras)
library(dplyr)
library(htmltools)
# original source: https://www.bloomberg.com/graphics/2021-german-election-results/
party_df <- tibble(
Party = c("SPD", "CDU/CSU", "Greens", "FDP", "AfD", "Left", "Other"),
Seats = c(206, 196, 118, 92, 83, 39, 1),
@tessam30
tessam30 / regression_example.R
Created June 16, 2021 17:28
Sample of how to fit a linear model in R
# Install packages needed for example
install.packages(c("tidyverse", "lindia"))
# Load libraries needed
library(tidyverse)
library(lindia)
# Load the data
df <- tibble::tribble(
~quantity, ~price, ~advertising,
@tessam30
tessam30 / dialog.html
Created February 19, 2021 21:45 — forked from arthurattwell/dialog.html
Google Sheets script to allow multi-select in cells with data-validation (adapted from https://www.youtube.com/watch?v=dm4z9l26O0I)
<div style="font-family: sans-serif;">
<? var data = valid(); ?>
<form id="form" name="form">
<? if(Object.prototype.toString.call(data) === '[object Array]') { ?>
<? for (var i = 0; i < data.length; i++) { ?>
<? for (var j = 0; j < data[i].length; j++) { ?>
<input type="checkbox" id="ch<?= '' + i + j ?>" name="ch<?= '' + i + j ?>" value="<?= data[i][j] ?>"><?= data[i][j] ?><br>
<? } ?>
<? } ?>
<? } else { ?>
@tessam30
tessam30 / r.snippets
Last active January 14, 2022 15:33
My rstudio snippets on gfe
snippet ohab "base si packages"
library(glitr)
library(glamr)
library(gisr)
library(tidyverse)
library(gophr)
library(scales)
library(sf)
library(extrafont)
library(tidytext)
@tessam30
tessam30 / SI_install.r
Created August 20, 2020 13:45
OHA SI install all packages
# Install all OHA packages
# List all packages below that need to be installed from USAID-OHA-SI github repo
pkg_list <- c("Wavelength", "glitr", "glamr", "gisr", "COVIDUtilities")
purrr::map(pkg_list, .f = ~devtools::install_github(paste0("USAID-OHA-SI/", .x)))
# Grab ICPI tools
devtools::install_github("ICPI/ICPIutilities")
@tessam30
tessam30 / country-bounding-boxes.py
Created December 20, 2017 13:39 — forked from graydon/country-bounding-boxes.py
country bounding boxes
# extracted from http//www.naturalearthdata.com/download/110m/cultural/ne_110m_admin_0_countries.zip
# under public domain terms
country_bounding_boxes = {
'AF': ('Afghanistan', (60.5284298033, 29.318572496, 75.1580277851, 38.4862816432)),
'AO': ('Angola', (11.6400960629, -17.9306364885, 24.0799052263, -4.43802336998)),
'AL': ('Albania', (19.3044861183, 39.624997667, 21.0200403175, 42.6882473822)),
'AE': ('United Arab Emirates', (51.5795186705, 22.4969475367, 56.3968473651, 26.055464179)),
'AR': ('Argentina', (-73.4154357571, -55.25, -53.628348965, -21.8323104794)),
'AM': ('Armenia', (43.5827458026, 38.7412014837, 46.5057198423, 41.2481285671)),
@tessam30
tessam30 / new_python_qgis_colorramps.xml
Created December 30, 2016 13:12 — forked from cossatot/new_python_qgis_colorramps.xml
New Python perceptually-uniform colormaps as color ramps for QGIS
<!DOCTYPE qgis_style>
<qgis_style version="0">
<symbols/>
<colorramps>
<colorramp type="gradient" name="Magma">
<prop k="color1" v="0,0,3,255"/>
<prop k="color2" v="251,252,191,255"/>
<prop k="stops" v="0.04;4,4,21,255:0.08;14,10,42,255:0.12;26,16,65,255:0.16;40,17,89,255:0.20;57,15,110,255:0.23;74,16,121,255:0.27;90,21,126,255:0.31;105,28,128,255:0.35;121,34,129,255:0.39;137,40,129,255:0.43;153,45,127,255:0.47;169,50,124,255:0.51;185,55,120,255:0.55;202,62,114,255:0.59;217,70,106,255:0.62;230,81,98,255:0.66;240,96,93,255:0.70;247,113,91,255:0.74;251,132,96,255:0.78;253,151,104,255:0.82;254,170,116,255:0.86;254,188,130,255:0.90;253,207,146,255:0.94;253,225,163,255:0.98;252,243,181,255"/>
</colorramp>
<colorramp type="gradient" name="Inferno">
@tessam30
tessam30 / tidyZika.R
Last active September 13, 2016 17:06
a#-------------------------------------------------------------------------------
# Name: 01_ZikaReshape
# Purpose: Reshape Zika data into a tidy dataframe
# Author: Tim Essam, Ph.D.
# Created: 2016/09/13
# Owner: USAID GeoCenter | OakStream Systems, LLC
# License: MIT License
#-------------------------------------------------------------------------------
# Load required libraries
@tessam30
tessam30 / index.html
Created September 15, 2014 13:43
Scatterplot
<!doctype HTML>
<meta charset = 'utf-8'>
<html>
<head>
<script src='//ramnathv.github.io/rCharts/libraries/widgets/polycharts/js/polychart2.standalone.js' type='text/javascript'></script>
<style>
.rChart {
display: block;