Skip to content

Instantly share code, notes, and snippets.

@sdtaylor
sdtaylor / install_old_packages.R
Last active April 24, 2017 22:29
Install all the packages that were in the prior version of R
prior_version = 3.3
library_path = .libPaths()[1]
library_path = substr(library_path, 1, nchar(library_path)-3)
old_library_path=paste0(library_path, prior_version)
old_packages = list.files(old_library_path)
install.packages(old_packages)
@sdtaylor
sdtaylor / swap_lines.sh
Created December 29, 2016 15:25
Linux swap file stuff
#Create a new file
sudo fallocate -l 4G /swapfile
#RW for root only
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
#check swap
@sdtaylor
sdtaylor / function.R
Created February 8, 2017 22:31
Use dplyr inside a function with arbitray column names
#Use dplyr inside a function with arbitray column names
#The dots stuff is from the internal workings of dplyr
#Don't forget the _ at the end of the group by.
#Other function also have the _ variation with the .dots argument available,
#but when I first made this in early 2016 not all of them did.
my_function=function(original_df, variables){
dots=lapply(variables, as.symbol)
summarized_data = original_data %>%
group_by_(.dots = dots ) %>%
summarize(freq=sum(freq)) %>%
@sdtaylor
sdtaylor / dplyr_lession.R
Created February 13, 2017 21:52
R Workshop dplyr() lesson
library(dplyr)
library(tidyr)
shrub_data<-read.csv("~/dplyrLesson/shrub_volume_experiment.csv")
########################
#some basics
#######################
#ordering rows!
#no more using shrub_data=shrub_data[order(shrub_data$site),]

Sunrise

Oh sunrise, you must be so lonely.
Hardly a soul spends time with you
before you coalesce into the day.

Your sister, sunset, is the Hollywood star
everyone knows. Yet sunrise, you are
just a hometown hero for early risers.

@sdtaylor
sdtaylor / windows_dir
Created April 11, 2017 16:11
R Windows directory stuff
> path.expand('~')
[1] "C:/Users/shawntaylor/Documents"
> normalizePath(path.expand('~'))
[1] "C:\\Users\\shawntaylor\\Documents"
> wd = getwd()
> wd
[1] "C:/Users/shawntaylor/Documents/portalPredictions"
> path.expand(wd)
[1] "C:/Users/shawntaylor/Documents/portalPredictions"
> normalizePath(path.expand(wd))

Paneer Sak

  • 1 pound (450 grams) fresh spinach, washed and steamed
  • 2 pinches asafetida
  • 1 tablespoons ghee or vegetable oil
  • 3 tablespoons water
  • 2 teaspoons ground coriander
  • 2/3 cup (150 milliliter) sour cream (optional
  • 1/2 teaspoon turmeric
  • 8 ounce (225 grams) paneer, cubed
  • 1/4 teaspoon cayenne pepper
@sdtaylor
sdtaylor / proj4sting.md
Last active June 4, 2020 02:18
Species and species ID's for USGS Tree Range shapefiles, https://www.fs.fed.us/nrs/atlas/littlefia/#
@sdtaylor
sdtaylor / get_forecast.R
Last active February 27, 2018 16:20
download climate locations for a single location
library(lubridate)
library(dplyr)
####################################################################################
#' Download downscaled climate forecast data
#'
#' Individual climate models available are are c('CFSv2','CMC1','CMC2','GFDL-FLOR','GFDL','NASA','NCAR'),
#' 'ENSMEAN' is the mean of all models.
#' lead_time is the months into the future to obtain forecasts. Max of 7
#' Default lat and lon are for Portal, AZ
@sdtaylor
sdtaylor / florida_winter_freezing_days.R
Last active December 2, 2020 14:33
North Florida Winter's
library(tidyverse)
library(cowplot)
#########################
# Get data
zipped_files = c("1997_daily.csv.zip", "1998_daily.csv.zip", "1999_daily.csv.zip", "2000_daily.csv.zip", "2001_daily.csv.zip", "2002_daily.csv.zip",
"2003_daily.csv.zip", "2004_daily.csv.zip", "2005_daily.csv.zip", "2006_daily.csv.zip", "2007_daily.csv.zip", "2008_daily.csv.zip",
"2009_daily.csv.zip", "2010_daily.csv.zip", "2011_daily.csv.zip", "2012_daily.csv.zip", "2013_daily.zip", "2014_daily.zip",
"2015_daily.zip", "2016_daily.zip", "2017_daily.zip", "2018_daily.zip","2019_daily.zip","2020_daily.zip")
data_folder = 'fawn_data/'