Skip to content

Instantly share code, notes, and snippets.

View jcquiroz's full-sized avatar

Juan-Carlos Quiroz jcquiroz

View GitHub Profile
sex ageYear ageMonth heightIn weightLb
f 11.91667 143 56.3 85
f 12.91667 155 62.3 105
f 12.75 153 63.3 108
f 13.41667 161 59 92
f 15.91667 191 62.5 112.5
f 14.25 171 62.5 112
f 15.41667 185 59 104
f 11.83333 142 56.5 69
f 13.33333 160 62 94.5
@jcquiroz
jcquiroz / server.R
Created May 15, 2013 20:26
my first shiny ... tatatannnnn
library(shiny)
library(datasets)
# We tweak the "am" field to have nicer factor labels. Since this doesn't
# rely on any user inputs we can do this once at startup and then use the
# value throughout the lifetime of the application
mpgData <- mtcars
mpgData$am <- factor(mpgData$am, labels = c("Automatic", "Manual"))
# Define server logic required to plot various variables against mpg
@jcquiroz
jcquiroz / kobe_data.txt
Created May 14, 2012 19:20
Example Kobe plot (Southern Hake)
list(structure(list(Ft = c(0.00828443, 0.142537, 0.205784, 0.19026,
0.225401, 0.295057, 0.224034, 0.227109, 0.19411, 0.261652, 0.261515,
0.28181, 0.319932, 0.261043, 0.221416, 0.30204, 0.189705, 0.229262,
0.20576, 0.189241, 0.182041, 0.16062, 0.198323, 0.19972, 0.119569,
0.13151, 0.154239, 0.176638, 0.174014, 0.202141, 0.217325, 0.232339,
0.249338), SB = c(398628, 372411, 327064, 299841, 278429, 254561,
268407, 256049, 248592, 261639, 224616, 199638, 161313, 165024,
137836, 115116, 113422, 107876, 132227, 126253, 135821, 124534,
128808, 117339, 95778.5, 129940, 124759, 116870, 108635, 100149,
92081.8, 86251.3, 83672.8), yr = 1978:2010), .Names = c("Ft",
@jcquiroz
jcquiroz / kobePlot.r
Created May 14, 2012 19:18
Kobe plot using ggplot
kobePlot <- function(dta, v, saveF = TRUE,...)
{
F20 <- v[1]
F40 <- v[2]
F40.F20 <- F40/F20
So <- v[3]
xxmax <- 1.4*max(dta$Ft,F40.F20)
kobe <- ggplot(dta, aes(x = Ft/v[1], y = SB/v[3])) +
theme_bw() + scale_y_continuous(limits=c(0,1)) +
@jcquiroz
jcquiroz / gist:1621223
Created January 16, 2012 14:55
simple_linear.dat
# nobs
10
# data
1 1.2 0.2
2 3.4 0.2
3 5.1 0.2
4 4.5 0.2
5 7.5 0.2
6 9.3 0.2
7 10.1 0.2
@jcquiroz
jcquiroz / gist:1621215
Created January 16, 2012 14:53
likelihoodStats.cxx
#include <admodel.h>
//=================================================================================
// Likelihoods for abundance indices or catch
//=================================================================================
dvar_vector nlikelihood(dvector observed, dvar_vector expected, dvector cv, int LikeType)
{
RETURN_ARRAYS_INCREMENT();
dvar_vector logLike;
@jcquiroz
jcquiroz / gist:1621193
Created January 16, 2012 14:47
simple_linear.tpl
GLOBALS_SECTION
#include <likelihoodStats.cxx>
DATA_SECTION
init_int nobs
init_matrix data(1,nobs,1,3)
PARAMETER_SECTION
init_bounded_number a(-0.5,0.5,1)
init_bounded_number b(0.1,3,1)
@jcquiroz
jcquiroz / gist:1573295
Created January 7, 2012 00:54
linear-model data
structure(list(nobs = 12, data = structure(list(x = c(2.3, 6.7,
7.5, 3.1, 4.6, 3.9, 8.7, 9.8, 10.1, 6.5, 7.3, 5.2), y = c(5,
13, 10, 5, 9, 8, 15, 20, 18, 13, 12, 9)), row.names = c(NA, -12L
), .Names = c("x", "y"), class = "data.frame")), .Names = c("nobs",
"data"))
@jcquiroz
jcquiroz / R
Created January 5, 2012 13:37
Plotting fisheries data
library(ggplot2)
library(reshape)
p <- ggplot(subset(reclas))
p1 <- p + geom_bar(aes(factor(length), obs), stat = "identity")
p2 <- p1 + facet_wrap(~year)
p3 <- p2 + geom_line(aes(factor(length), pre, group = 1))
p4 <- p3 + opts(axis.text.x = theme_text(hjust = 0))
p4