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
| make_data <- function(slope =1, int = 1, sd_e = 5, group=1, x=1:20){ | |
| ret <- data.frame(x=x) | |
| ret <- within(ret, { | |
| y <- rnorm(length(x), int + slope*x, sd_e) | |
| group <- group | |
| }) | |
| ret | |
| } |
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(nlme) | |
| library(ggplot2) | |
| library(lubridate) | |
| library(dplyr) | |
| #download data from https://www.google.com/trends/explore#q=%22i%20cant%20even%22&cmpt=q&tz=Etc%2FGMT%2B5 | |
| i_cant_even <- read.csv("./i_cant_even.csv", skip=4) | |
| #reformat weeks | |
| i_cant_even$Week <- as.character(i_cant_even$Week) |
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
| #devtools::install_github("rstudio/leaflet", ref="feature/color-legend") | |
| library(leaflet) | |
| library(RColorBrewer) | |
| set.seed(100) | |
| pdf <- data.frame(Latitude = runif(100, -90,90), Longitude = runif(100, -180,180)) | |
| #make a property with colors | |
| pdf$Study <- rep(1:10,10) | |
| #need to create a pal using colorbin |
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
| #Load the library and make a basic map | |
| library(leaflet) | |
| leaflet() %>% addTiles() | |
| #Show a map with a satellite picture on it | |
| leaflet() %>% | |
| addTiles(urlTemplate="http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}") | |
| #Make a demo fake data set |
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
| ######################################################################### | |
| # Code to import and make useful | |
| # Spalding et al. 2007's Marine Ecoregions of the World | |
| # Data provided by http://www.marineregions.org/downloads.php | |
| # by Jarrett Byrnes | |
| # last updated 3/26/2015 | |
| ######################################################################### | |
| ###################### | |
| ##### Load Libraries |
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
| #just create a range of values | |
| grdVals <- function(x, bound=0.01) seq(range(x)[1]-bound, range(x)[2]+bound, length.out=50) | |
| #instantiate a new persp object for a scatterplot | |
| makeScatterBox <- function(x,y,z, bound=0, ...){ | |
| x <- grdVals(x, bound=bound) | |
| y <- grdVals(y, bound=bound) | |
| z <- grdVals(z, bound=bound) | |
| z <- matrix(rep(z, 50), nrow=50) |
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
| \documentclass{article} | |
| \begin{document} | |
| <<echo=FALSE>>= | |
| activityDF <- structure(list(julian_day = 1:365, food = c(92.6182247978374, | |
| 199.361820535986, 128.619308542186, 131.048504694701, 44.6344539529983, | |
| 139.02542881751, 118.815437972886, 85.5963235153311, 73.9459098960665, | |
| 85.6671795660157, 195.954639346317, 192.942941724749, 193.341526021202, | |
| 142.419581610027, 130.23002915561, 232.843857188757, 105.14817987285, | |
| 131.58751463704, 123.30056211349, 150.447279408636, 138.40775613945, |
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(multifunc) | |
| data(all_biodepth) | |
| allVars<-qw(biomassY3, root3, N.g.m2, light3, N.Soil, wood3, cotton3) | |
| germany<-subset(all_biodepth, all_biodepth$location=="Germany") | |
| vars<-whichVars(germany, allVars) | |
| #re-normalize N.Soil so that everything is on the same sign-scale (e.g. the maximum level of a function is the "best" function) | |
| germany$N.Soil<- -1*germany$N.Soil +max(germany$N.Soil, na.rm=TRUE) |
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
| ############################################################################################ | |
| # | |
| # Script to turn lat/long data into | |
| # marine ecoregions using Spalding's Marine Ecoregions | |
| # of the World (MEOW). | |
| # | |
| # To run, first acquire the appropriate GIS files from | |
| # http://maps.tnc.org/gis_data.html and unzip them into | |
| # a directory (MEOW-TNC) - then go from there. | |
| # |
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(multifunc) | |
| library(wesanderson) | |
| data(all_biodepth) | |
| allVars<-qw(biomassY3, root3, N.g.m2, light3, N.Soil, wood3, cotton3) | |
| germany<-subset(all_biodepth, all_biodepth$location=="Germany") | |
| vars<-whichVars(germany, allVars) | |
| #re-normalize N.Soil so that everything is on the same sign-scale (e.g. the maximum level of a function is the "best" function) |