Skip to content

Instantly share code, notes, and snippets.

View alfcrisci's full-sized avatar

Alfonso alfcrisci

View GitHub Profile
@alfcrisci
alfcrisci / ecoODE.R
Created August 1, 2020 09:48 — forked from emhart/ecoODE.R
Examples of ODE's in R from classic ecological models with a simple M-W extension on I
#' Description: Code using deSolve for some simple ecological ODE models
#' There are 3 examples, one is a simple LV Pred-Prey example with plots
#' The next is a Macarthur-Wilson model with plots of both the species curve and the equlibrium points
#' The last plot is a quick crack at putting stochasticity into the model by adding oscillations in I with t.
#' LV code is modified from a blog post here: http://assemblingnetwork.wordpress.com/2013/01/31/two-species-predator-prey-systems-with-r/
#' Other additions are my own
#'
#' Author: Edmund Hart
#' Date: 3/28/2013
#' E-mail: edmund.m.hart@gmail.com
@alfcrisci
alfcrisci / GCMSAgilentDfileImport
Created February 26, 2019 14:28 — forked from benmarwick/GCMSAgilentDfileImport
Function to import Agilent GCMS Chemstation D files in R
##' Function readDFile
##'
##' Function readDFile
##' @param pathname the pathname of the directory containing the data to import
##' @return outData Output is a matrix of ion counts with rows as scantime and
##' columns as mass, and the respective values as labels
##' @export
readDFile<-function(pathname){
filename<-file.path(pathname,'DATA.MS')
@alfcrisci
alfcrisci / GeoTIFF_leafletwidget_generator.r
Created May 17, 2016 07:42 — forked from noerw/GeoTIFF_leafletwidget_generator.r
R script to visualize GeoTIFFs in a Leaflet Map. Generates an HTML file containing this map
# dependencies on fedora23:
# gdal-devel geos-devel proj-devel proj-nad proj-epsg
library(htmlwidgets)
library(raster)
library(leaflet)
# PATHS TO INPUT / OUTPUT FILES
projectPath = "/home/kreis/git/geotiff/"
#imgPath = paste(projectPath,"data/cea.tif", sep = "")
@alfcrisci
alfcrisci / PDF-2-text-or-CSV.r
Created May 16, 2016 21:19 — forked from benmarwick/PDF-2-text-or-CSV.r
Convert PDFs to text files or CSV files (DfR format) with R
# Here are a few methods for getting text from PDF files. Do read through
# the instructions carefully! NOte that this code is written for Windows 7,
# slight adjustments may be needed for other OSs
# Tell R what folder contains your 1000s of PDFs
dest <- "G:/somehere/with/many/PDFs"
# make a vector of PDF file names
myfiles <- list.files(path = dest, pattern = "pdf", full.names = TRUE)
library(SPARQL)
library(ggplot2)
library(rworldmap)
wdqs <- "https://query.wikidata.org/bigdata/namespace/wdq/sparql"
query = "PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX v: <http://www.wikidata.org/prop/statement/>
@alfcrisci
alfcrisci / turkey-daily-protests.R
Created May 9, 2016 14:13 — forked from andybega/turkey-daily-protests.R
GDELT and ICEWS counts of daily protest events in Turkey from 15 May to 15 June 2013.
# Libraries
library(RMySQL)
# Connect to server
conn <- dbConnect(MySQL(), user="ab428", password="",
dbname="event_data", host="")
country <- "Turkey"
start.date <- "2013-05-15"
end.date <- "2013-06-15"
@alfcrisci
alfcrisci / gdata_read.py
Created December 30, 2015 13:35 — forked from andreagrandi/gdata_read.py
Read a Google Docs spreadsheet document from Python.
# Copyright (c) 2013, Andrea Grandi and individual contributors.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# 1) Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# 2) Redistributions in binary form must reproduce the above copyright notice,
@alfcrisci
alfcrisci / fit.R
Last active August 29, 2015 14:23 — forked from mollietaylor/fit.R
ols <- lm(Temp ~ Solar.R,
data = airquality)
summary(ols)
str(ols)
plot(Temp ~ Solar.R,
data = airquality)
abline(ols)
library(leaflet)
## OSM
leaflet() %>%
setView(-97.3606922, 32.7084083, zoom = 16) %>%
addTiles()
## OSM black-and-white
@alfcrisci
alfcrisci / lintemp.R
Last active August 29, 2015 14:22 — forked from johnbaums/lintemp.R
#### Temporal Interpolation ####################################################
# Perform cell-wise linear interpolation between multiple raster layers, and
# extrapolation beyond the upper limit of input data. Output is saved in .tif
# format.
#
# Arguments
# s: a rasterStack containing the time slices to be interpolated
#
# xin: a numeric vector that indicates the times associated with layers in s (in
# the same order as the layers of s - see names(s))