Skip to content

Instantly share code, notes, and snippets.

Avatar

Michael Dorman michaeldorman

View GitHub Profile
View coord_sf_lim.R
library(sf)
library(ggplot2)
# Data
nc = st_read(system.file("shape/nc.shp", package="sf"))
map = nc
dat = nc[5, ]
# Plot 1
ggplot() +
@michaeldorman
michaeldorman / packages_proportion.R
Last active Apr 25, 2020
Calculate top 15 commonly used R packages given a directory with R scripts
View packages_proportion.R
# Directory with R scripts
setwd("~/Sync/BGU")
# Prepare data
files = list.files(pattern = "\\.R$", recursive = TRUE)
dat = lapply(files, readLines)
dat = lapply(dat, function(x) x[grepl("library\\(", x)])
dat = lapply(dat, function(x) gsub(".*library\\(", "", x))
dat = lapply(dat, function(x) gsub("\\).*", "", x))
dat = lapply(dat, function(x) gsub('"', '', x))
View map.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View index.html
<!DOCTYPE html>
<html>
<head>
<title>Simple Leaflet Map</title>
<meta charset="utf-8" />
<link
rel="stylesheet"
href="http://cdn.leafletjs.com/leaflet-0.7/leaflet.css"
/>
</head>
View loocv_lm.R
loocv = function(formula, data) {
pred = rep(NA, nrow(data))
for(i in 1:nrow(data)) {
fit = lm(formula = formula, data = data[-i, ])
pred[i] = predict(fit, data[i, ])
}
@michaeldorman
michaeldorman / IMS_Map.R
Last active Aug 29, 2015
R script to create and publish interpolated temperature map of Israel
View IMS_Map.R
###############################################################
# Code to publish interpolated temperature map #
# based on current observations from the #
# Israel Meteorological Service (IMS) website #
# Author: Michael Dorman #
###############################################################
library(XML)
library(httr)
library(plyr)