Skip to content

Instantly share code, notes, and snippets.

View seananderson's full-sized avatar

Sean Anderson seananderson

View GitHub Profile
@seananderson
seananderson / knitr-themes
Last active December 22, 2015 16:59
A demonstration of knitr LaTeX themes
library(knitr)
themes <- knit_theme$get()
opening <- "
<<>>=
"
opening_no_echo <- "
<<echo=FALSE>>=
"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@seananderson
seananderson / make-bisc-888-doc.r
Last active December 29, 2015 03:39
A script to stitch together figures, captions, and code from many people.
# Pull together figs, code, and captions into a knitr TeX document
# Sean Anderson November 24, 2013
# define some knitr chunks to print below:
opening <- "
<<>>=
"
closing <- "@\n"
preamble <- readLines("intro.Rnw")
postamble <- "\\end{document}"
@seananderson
seananderson / gist:7683040
Created November 27, 2013 20:55
ss3sim-ms.md changes since last draft
diff --git a/inst/ms/ss3sim-ms.md b/inst/ms/ss3sim-ms.md
index 5942428..9c4ece0 100644
--- a/inst/ms/ss3sim-ms.md
+++ b/inst/ms/ss3sim-ms.md
@@ -1,18 +1,17 @@
# Abstract
Simulation testing is an important approach
-to evaluating fishery stock-assessment methods.
-In the last decade, the fisheries stock-assessment modeling framework
@seananderson
seananderson / gist:7683078
Created November 27, 2013 20:57
ss3sim-ms.md changes in last day or so
diff --git a/inst/ms/ss3sim-ms.md b/inst/ms/ss3sim-ms.md
index 69cf7fc..9c4ece0 100644
--- a/inst/ms/ss3sim-ms.md
+++ b/inst/ms/ss3sim-ms.md
@@ -5,13 +5,13 @@ to evaluating fishery stock assessment methods.
In the last decade, the fisheries stock assessment modeling framework
Stock Synthesis (SS3) has become widely-used around the world.
However, there lacks a generalized
-and scriptable framework for running SS3 simulations.
+and scriptable framework for SS3 simulation testing.
@seananderson
seananderson / 0_reuse_code.js
Created March 27, 2014 18:09
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@seananderson
seananderson / 8-ways-to-selectively-alter-a-data-frame.md
Last active August 29, 2015 14:17
8 ways to selectively alter data in an R data frame

From Stats Beerz on 2015-03-23. Here's the question: How can you substitute values in one column based on values in another column? There are many many ways. Here are a few,

Create some fake data:

d <- data.frame(
  rel = c("yes", "no", "yes"),
  troph = c(1, 2, 3))

d

# Vocabulary
To quote Hadley Wickham from his excellent book *Advanced R* <http://adv-r.had.co.nz/Vocabulary.html>:
"An important part of being fluent in R is having a good working vocabulary. [...] I have listed the functions that I believe constitute such a vocabulary. You don't need to be intimately familiar with the details of every function, but you should at least be aware that they all exist. If there are functions in this list that you've never heard of, I strongly recommend that you read their documentation."
I encourage you to look through Hadley's full list at the link above.
Below, I have reduced Hadley's list to those most relevant to this workshop. It will help you follow the material if you are at least somewhat aware of the following functions and their purpose.
# Because of our limited time, it is critical that you arrive
# with all of the necessary software and R packages installed.
# If you are having any issues with this, first see if there is
# a colleague who can help you. If you are stuck, please get in
# touch with me (Sean, sean "at" seananderson.ca) before the workshop.
# The following R code should walk you through it.
# You will need to have the latest version of R, version 3.4.0 or above.
# Check with:
sessionInfo()
Process: RStudio [7928]
Path: /Applications/RStudio.app/Contents/MacOS/RStudio
Identifier: org.rstudio.RStudio
Version: 1.0.136 (1.0.136)
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: RStudio [7928]
User ID: 501
Date/Time: 2016-12-16 09:49:10.317 -0800