Skip to content

Instantly share code, notes, and snippets.

View dickoa's full-sized avatar

Ahmadou Dicko dickoa

View GitHub Profile
@dickoa
dickoa / solarSplines.R
Last active February 20, 2017 05:33
A R version of the Python script for splines interpolation kindly provided by StormMiner. The code is a straight conversion thus not optimized but it works. Have fun,
require(ncdf4)
loadMesonetData <- function(filename, stationFilename = "station_info.csv") {
data <- read.csv(file.path(data_path, filename))
station_data <- read.csv(file.path(data_path, stationFilename))
list(data = data[,-1], dates = data[,1], station_data = station_data)
}
@dickoa
dickoa / read_gistemp.R
Last active August 29, 2015 14:10
Reading NASA global temperature index using R
### Download file
url <- "http://data.giss.nasa.gov/gistemp/tabledata_v3/GLB.Ts+dSST.txt"
tmp <- tempfile()
download.file(url, destfile = tmp, method = "curl")
### Read the file and select colnames
dat <- readLines(tmp)
col_names <- unique(grep("^Year", dat, value = TRUE)) ## select colnames
col_names <- strsplit(col_names, "\\s+")[[1]]
library(foreign)
set.seed(1)
df <- as.data.frame(matrix(rnorm(1e8), ncol = 10))
write.csv(df, "/tmp/test.csv", row.names = FALSE)
write.dta(df, "/tmp/test.dta")
@dickoa
dickoa / weighted_mean.R
Created November 11, 2015 09:05
Custom function in dplyr psql backend
library(dplyr)
library(RPostgres)
mydb <- src_postgres(dbname = "yourdb"
user = "user",
password = "password",
host = "localhost",
port = 5432L)

Keybase proof

I hereby claim:

  • I am dickoa on github.
  • I am dickoa (https://keybase.io/dickoa) on keybase.
  • I have a public key whose fingerprint is 188B 5A3A C523 96A3 1BED AAA6 D4F1 DBD4 6340 C474

To claim this, I am signing this object:

@dickoa
dickoa / hrp_recipe.json
Created February 6, 2019 12:48
HXL hrp recipe
{
"name": "hrp",
"title": "Humanitarian Responses Plan",
"type": "cookbook",
"columns": [
"#targeted",
"#region",
"#country",
"#adm1"
],
@dickoa
dickoa / hno_sector_recipe.json
Last active February 26, 2019 16:26
HNO HXL recipe with sector support
{
"name": "hno_sector",
"title": "Humanitarian Needs Overview",
"type": "cookbook",
"columns": [
"#inneed",
"#region",
"#country",
"#adm1",
"#sector"
{
"name": "hno_sector_drc",
"title": "Humanitarian Needs Overview for DRC",
"type": "cookbook",
"columns": [
"#inneed",
"#sector"
],
"recipes": [
{
{
"name": "hno_ukr",
"title": "Ukraine: Humanitarian Needs Overview",
"type": "cookbook",
"columns": [
"#inneed",
"#affected",
"#loc",
"#country"
],
year poc n
2010 Internally displaced persons 25
2010 UNRWA refugees 4.7
2010 UNHCR refugees 10.5
2010 Asylum-seekers 0.8
2010 Venezuelans displaced abroad 0
2011 Internally displaced persons 22.4
2011 UNRWA refugees 4.8
2011 UNHCR refugees 10.4
2011 Asylum-seekers 0.9