Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(bib2df) | |
x = bib2df('manuscript/sample.bib') | |
x$ANNOTE=NA | |
x$MENDELEY.GROUPS=NA | |
x$MENDELEY.TAGS=NA | |
x$ABSTRACT=NA | |
x$FILE=NA | |
x$KEYWORDS=NA |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias aptupdate='sudo apt-get update' | |
alias aptupgrade='sudo apt-get upgrade' | |
alias aptinstall='sudo apt-get install' | |
alias aptremove='sudo apt-get remove' | |
function csvhead { | |
head "$@" | sed 's/,,/, ,/g;s/,,/, ,/g' | column -t -s, | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
basemap = map_data('state') | |
lat_range = c(20,60) | |
lon_range = c(-150,50) | |
ggplot() + | |
geom_polygon(data = basemap, aes(x=long, y = lat, group = group), fill=NA, color='black', size=1.5) + | |
scale_x_continuous(breaks=seq(lon_range[1],lon_range[2],10), minor_breaks = seq(lon_range[1],lon_range[2],1)) + |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(ggplot2) | |
# Make a vector of colors of size n based on an RColorBrewer palette | |
# or list of colors. | |
get_extended_palette = function(original_palette = 'Paired', n){ | |
brewer_palettes = rownames(RColorBrewer::brewer.pal.info) | |
if(length(original_palette)>=2){ | |
original_palette_values = original_palette | |
} else if(original_palette %in% brewer_palettes){ | |
original_palette_values = RColorBrewer::brewer.pal(9, original_palette) # most of the palettes have 9 colors to start with |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run these first to get all the relevant packages | |
# For R 4.0 on ubuntio 18.04 | |
# from https://www.digitalocean.com/community/tutorials/how-to-install-r-on-ubuntu-18-04 | |
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9 | |
sudo add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran40/' | |
sudo apt-get update | |
sudo apt-get install r-base | |
# The following packages are also needed for various things in the tidyverse |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Adapted from https://stackoverflow.com/a/7267364/1036500 by Andrie de Vries | |
# This is it: theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5)) | |
library(ggplot2) | |
td <- expand.grid( | |
hjust=c(0, 0.5, 1), | |
vjust=c(0, 0.5, 1), | |
angle=c(0, 45, 90), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(neonUtilities) | |
library(geoNEON) | |
sites = c('JORN','TALL','BART','BARR', 'HARV','YELL') | |
for(site_id in sites){ | |
woody_structure=tryCatch(neonUtilities::loadByProduct('DP1.10098.001', site=site_id, | |
startdate = '2018-01', enddate = '2018-12', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(sf) | |
# where lon, lat are columns for longitude, latitude, respectively. | |
# Any other columns are retained in the sf data.frame. | |
read_csv('site_list.csv') %>% | |
st_as_sf(coords = c('lon','lat'), crs=4326) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
# Create a "date bin" data.frame with columns c('start','end') | |
# start_date, and last_date are dates | |
# time_bin_size should be string like '1 year','6 month', etc. see ?seq.Date for more examples | |
bin_dates = function(first_date, last_date, time_bin_size='1 year'){ | |
if(!(lubridate::is.Date(first_date) & lubridate::is.Date(last_date))) stop('first_date and last_date must be dates') | |
if(first_date>=last_date) stop('first_date must come before last date') | |
full_range = seq.Date(first_date,last_date, by=time_bin_size) |