Skip to content

Instantly share code, notes, and snippets.

View aleruete's full-sized avatar
:octocat:

Alejandro Ruete aleruete

:octocat:
View GitHub Profile
####################################
# Run zonal statistics in parallel #
####################################
# Clear workspace
rm(list=ls())
# Libraries
library(raster)
library(gstat)
@rmarrotte
rmarrotte / Circuitscape in R (Windows).R
Last active December 20, 2018 14:25
Simple script that shows how to run Circuitscape through R under Windows. It runs an examples found in the Circuitscape examples folder
########################################
#### Getting started ####
########################################
# Make a place holder for the cs_run.exe path
CS_exe <- 'C:/"Program Files"/Circuitscape/cs_run.exe' # Don't forget the "Program Files" problem
# We want to run one of the CS examples found in /examples/, first we need to fix the .ini file
# We first read in the .ini file and then we change the arguments
Example_lines <- readLines("C:/Program Files/Circuitscape/examples/eight_neighbor_example.ini")
@sckott
sckott / ropensci_parallel.md
Last active March 21, 2016 17:03
example parallel workflow with an rOpenSci package

Example parallel workflow

In this example, we use the rgbif package to search for occurrence (lat/long) data for 1000 species

Install and load rgbif

install.packages("rgbif")
library("rgbif")
@florianhartig
florianhartig / gaussianAutoregressiveExample.jags.
Last active November 9, 2021 11:07
A modification of code posted originally by Petr Keil http://www.petrkeil.com/?p=1910, to illustrate some comments I made in response to this blog post
library(mvtnorm) # to draw multivariate normal outcomes
library(R2jags) # JAGS-R interface
# function that makes distance matrix for a side*side 2D array
dist.matrix <- function(side)
{
row.coords <- rep(1:side, times=side)
col.coords <- rep(1:side, each=side)
row.col <- data.frame(row.coords, col.coords)
D <- dist(row.col, method="euclidean", diag=TRUE, upper=TRUE)
@josecarlosgonz
josecarlosgonz / GoogleMapsAndR.md
Last active July 22, 2022 07:56
How to use Google's API with R

Using Google Maps API and R

This script uses RCurl and RJSONIO to download data from Google's API to get the latitude, longitude, location type, and formatted address

library(RCurl)
library(RJSONIO)
library(plyr)
#import relevant packages
library(gstat)
library(sp)
library(nlme)
#create simulated data, lat and lon from uniformly distributed variable, exp1 and exp2 from random normal
set.seed(2)
samp.sz<-400
lat<-runif(samp.sz,-4,4)
lon<-runif(samp.sz,-4,4)