Skip to content

Instantly share code, notes, and snippets.

View cengel's full-sized avatar

Claudia Engel cengel

  • California, USA
View GitHub Profile
@cengel
cengel / GreatCircleFlights.R
Created March 22, 2012 23:14
Great Circles in ggplot
library(maps)
library(geosphere)
library(plyr)
library(ggplot2)
library(sp)
airports <- read.csv("http://www.stanford.edu/~cengel/cgi-bin/anthrospace/wp-content/uploads/2012/03/airports.csv", as.is=TRUE, header=TRUE)
flights <- read.csv("http://www.stanford.edu/~cengel/cgi-bin/anthrospace/wp-content/uploads/2012/03/PEK-openflights-export-2012-03-19.csv", as.is=TRUE, header=TRUE)
# aggregate nunber of flights
@cengel
cengel / rpyDemo.py
Created April 10, 2012 05:22
A simple example to use ggplot R library from within Python
import pandas
import rpy2.robjects as robjects
from rpy2.robjects.packages import importr
from rpy2.robjects.lib import grid
from rpy2.robjects.lib import ggplot2
## read in the distances to railroad (we calculated)
neardist = pandas.read_csv('data/NearDistance.csv')
## convert to R dataframe, via Python Dictionary data type
@cengel
cengel / server.R
Created November 15, 2012 00:44
Shiny intro tutorial example rewritten for ggplot2
library(shiny)
library(datasets)
library(ggplot2) # load ggplot
# Define server logic required to plot various variables against mpg
shinyServer(function(input, output) {
# Compute the forumla text in a reactive function since it is
# shared by the output$caption and output$mpgPlot functions
formulaText <- reactive(function() {
@cengel
cengel / README.md
Last active April 8, 2016 17:22
IRiSS Lunch & Learn: GIS

Software for GIS

IRiSS Lunch & Learn - April 8, 2016

  • Claudia Engel, Department of Anthropology & Center for Interdisciplinary Digital Research

Follow along here: bit.ly/software4gis

Software

  • Desktop GIS - ArcGIS Desktop. Install from here to take advantage of the Stanford Campus License (Stanford affiliated only). New: ArcGIS Pro
# May have to install xckd fonts through FontBook.
library(xkcd)
# the data to make the bars
df <- data.frame(x=c(1, 3), y=c(20, 2))
# the figures
ratioxy <- diff(range(df$x)) / diff(range(df$y))
mapping <- aes(x, y,
scale,
##
## this snippet loops through a directory with rasters and crates polygons
## using a call to gdal_polygonize.py
## (for Mac, with kynchaos GDAL framework)
##
# make sure to not mess up the paths here!
setwd("root/dir")
indir <- "rasterdir-ending-with-slash/"
outdir <- "polydir-ending-with-slash/"
# Original Idea and code by Jules Beley
# https://github.com/julesbeley/Erasmusmap/blob/master/Erasmus.R
# https://medium.com/@jules.beley/making-a-map-with-eu-data-on-r-erasmus-exchanges-by-country-3f5734dcd4ff
library(tidyverse)
library(maps)
library(countrycode)
download.file("http://data.europa.eu/euodp/data/uploads/EAC/SM_2012_13_20141103_01.csv", "erasmus.csv") # this may take a little while
@cengel
cengel / script.R
Last active August 14, 2020 19:14
NCCU R Intro Carpentries Workshop Notes
########################################
### Intro to R NCCU, Aug 12-14, 2020 ###
########################################
# this is the workshop script
# get working directory:
getwd() # ctrl + enter to execute this line
# just a test shift + ctrl + c > make a comment (more shortcuts under Tools > shortcuts)