Skip to content

Instantly share code, notes, and snippets.

#function that extracts a depth (in meters) from a given lon lat from bathymetric data downloaded from online data using analyzepsat package. The file bathy.rds has already been downloaded by Cindy and is used below for BATH in the function
# General comment: Try to use underscores instead of periods in names, like depth.df => depth_df because
# periods in variable names has special meaning in R and I think it makes code harder to read. This is
# very much personal preference though as it won't make your code not work.
bathy = readRDS(file="bathy.rds")
depth_df <- btrack #this can be any data frame that has lon lat, in this case, column headings are "Lon_E" and "Lat_N"
depth_df$bottom_depth <- NA #setup empty column for bottom depth to be filled by for loop below
@amoeba
amoeba / README.md
Last active August 29, 2015 14:20
2015 Bristol Bay "Family" Size

2015 Bristol Bay "Family" Size

In the Bristol Bay, Alaska sockeye gillnet fishery, permits are attached to an individual person instead of a vessel. While you can apply to have a second permit, it's also possible for someone you know, including a family member, to hold a permit for you. Looking at the most recent 2015 data, how many permits are attached to a given last name? I used last name because it's the only way I could attempt to get at how many permits a family holds. Of course, there are popular last names and, for that situation, this analysis lumps numerous families together.

Uses d3.js to visualize the most recent 2015 permit data from the Alaska CFEC.

2015 Bristol Bay "Family" Size

In the Bristol Bay, Alaska sockeye gillnet fishery, permits are attached to an individual person instead of a vessel. While you can apply to have a second permit, it's also possible for someone you know, including a family member, to hold a permit for you. Looking at the most recent 2015 data, how many permits are attached to a given last name? I used last name because it's the only way I could attempt to get at how many permits a family holds. Of course, there are popular last names and, for that situation, this analysis lumps numerous families together.

Uses d3.js to visualize the most recent 2015 permit data from the Alaska CFEC.

# animation-2.r
# author: Bryce Mecum ([email protected])
#
# Animations in R Tutorial
# Part 2 of 6
#
# Extend part 1 by plotting a random (uniform) walk starting in the bottom
# right-hand corner and moving North and West.
library(maps)
@amoeba
amoeba / 00check.log
Created May 30, 2015 06:29
R CMD check for iptools
* using log directory ‘/Users/bryce/src/iptools/..Rcheck’
* using R version 3.2.0 (2015-04-16)
* using platform: x86_64-apple-darwin14.3.0 (64-bit)
* using session charset: UTF-8
* using option ‘--as-cran’
* checking for file ‘./DESCRIPTION’ ... OK
* checking extension type ... Package
* this is package ‘iptools’ version ‘0.2.0’
* checking CRAN incoming feasibility ... NOTE
Maintainer: ‘Bob Rudis <[email protected]>’
{"name":"He who is called I Am","children":[{"name":"Heinaken Rouse"},{"name":"Absolute Chaos","children":[{"name":"P S Y C H O","children":[{"name":"Swift Avenger"},{"name":"Dereisbaer"},{"name":"Me mighty mule III"},{"name":"Me mighty mule II"},{"name":"Yeviii"},{"name":"Yevii"},{"name":"Immortalbob","children":[{"name":"Yeni ibn Sol"},{"name":"Isawa Nodotai"},{"name":"R A D W A R"},{"name":"Stealer of Hope"},{"name":"Gildash"},{"name":"Reya"},{"name":"Onika"},{"name":"Tao-Lynn"},{"name":"Bhai Dayala"},{"name":"Drid's Ghost"}]},{"name":"Mage of Bob","children":[{"name":"Treasure Chest"},{"name":"Kepeliza"},{"name":"Fiz the Wiz"},{"name":"Aresaeolusa"},{"name":"W A R Dragon"},{"name":"Teena al Tirips"},{"name":"Nattalla"},{"name":"Granto"}]},{"name":"Digiorno","children":[{"name":"Scribble"},{"name":"Leigh Ann"},{"name":"Sei Chaun"},{"name":"Lythica"}]},{"name":"Bob the Addlepated","children":[{"name":"Shambling Archivist"},{"name":"Tzu Li Tsao"},{"name":"Kain Slambert"},{"name":"Sorry Ibn Drinkin'"},{"name"
def mymethd():
if True == True
return True
else
return None
# Example from http://www.w3.org/2007/OWL/wiki/PrimerExampleTurtle
f:Marriage rdf:type owl:Class .
_:x14 rdf:type owl:Class ;
owl:unionOf (f:CivilMarriage f:ReligiousMarriage) .
f:Marriage owl:equivalentClass _:x14 .
@amoeba
amoeba / dply-tally.R
Created October 14, 2015 04:26
dplyr's tally() function
library(dplyr)
# Set up an example data frame
stations = c("A", "B", "C")
species = c("M", "N", "O", "P", "Q")
baseline = c(5, 50, 500)
n <- 25
mydf <- data.frame(station=sample(stations, n, replace=TRUE), species=sample(species, n, replace=TRUE))
mydf$baseline <- baseline[match(mydf$station, stations)]
library(rvest)
url <- "http://access.afsc.noaa.gov/REEM/WebDietData/DietTable.php?NODC=8857041501&Year=2007&Region=GOA"
page <- read_html(url)
column_names <- page %>% html_nodes(".afscbody table tr:first-child td ") %>% html_text()
column_names
table_data <- page %>% html_nodes(".afscbody table tr:not(:first-child) td ") %>% html_text()
table_data