Skip to content

Instantly share code, notes, and snippets.

View dickoa's full-sized avatar

Ahmadou Dicko dickoa

View GitHub Profile
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 / 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]]
@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)
}