This file contains 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
## read in the CET data | |
`loadCET` <- function() { | |
CET <- url("http://www.metoffice.gov.uk/hadobs/hadcet/cetml1659on.dat") | |
on.exit(close(CET)) | |
cet <- read.table(CET, sep = "", skip = 6, header = TRUE, | |
fill = TRUE, na.string = c(-99.99, -99.9)) | |
names(cet) <- c(month.abb, "Annual") | |
## remove last row of incomplete data | |
cet <- cet[-nrow(cet), ] # FIXME: this removes the last row regardless | |
## get rid of the annual too - store for plotting |
This file contains 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
Verifying that +ucfagls is my blockchain ID. https://onename.com/ucfagls |
This file contains 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
asciify <- function(df, pad = 1, ...) { | |
## error checking | |
stopifnot(is.data.frame(df)) | |
## internal functions | |
SepLine <- function(n, pad = 1) { | |
tmp <- lapply(n, function(x, pad) paste(rep("-", x + (2* pad)), | |
collapse = ""), | |
pad = pad) | |
paste0("+", paste(tmp, collapse = "+"), "+") | |
} |
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 2 columns, instead of 5. in line 1.
This file contains 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
## Subset of data used in Rose et al (2012) Geochimica et Cosmochimica Acta 82, 113–135 doi: http://doi.org/10.1016/j.gca.2010.12.026 | |
SiteCode,Date,SoilType,Region,Hg | |
CHNA,2000,thin,NW,3.84339855275794 | |
CHNA,1990,thin,NW,5.42461797827638 | |
CHNA,1980,thin,NW,8.81972984714937 | |
CHNA,1970,thin,NW,11.4174572948292 | |
CHNA,1960,thin,NW,16.513540420367 | |
CHNA,1950,thin,NW,16.5120469510654 | |
CHNA,1940,thin,NW,11.1888397621818 | |
CHNA,1930,thin,NW,11.6222216338607 |
This file contains 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
## read in the CET data | |
CET <- url("http://www.metoffice.gov.uk/hadobs/hadcet/cetml1659on.dat") | |
cet <- read.table(CET, sep = "", skip = 6, header = TRUE, | |
fill = TRUE, na.string = c(-99.99, -99.9)) | |
names(cet) <- c(month.abb, "Annual") ## fix up df names | |
## remove last row of incomplete data | |
cet <- cet[-nrow(cet), ] | |
## get rid of the annual too - store for plotting | |
rn <- as.numeric(rownames(cet)) |
We can make this file beautiful and searchable if this error is corrected: Illegal quoting in line 1.
This file contains 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
## leafHeight is in cm.; visited, 1 == TRUE, 0 == FALSE" | |
"leafHeight","visited" | |
67,1 | |
84,1 | |
49,1 | |
70,1 | |
77,1 | |
77,1 | |
66,1 | |
65,1 |
This file contains 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
Sample | upperDepth | lowerDepth | ageBP | ageError | calUpper | calLower | |
---|---|---|---|---|---|---|---|
SRR-4556 | 20 | 22 | 355 | 35 | 509 | 307 | |
SRR-4557 | 26 | 28 | 465 | 35 | 542 | 480 | |
SRR-4558 | 32 | 34 | 635 | 35 | 671 | 545 | |
SRR-4559 | 38 | 40 | 740 | 35 | 732 | 666 | |
SRR-4560 | 44 | 46 | 865 | 35 | 916 | 691 | |
SRR-4561 | 50 | 52.5 | 870 | 35 | 918 | 692 | |
SRR-4562 | 56 | 58 | 985 | 35 | 967 | 795 | |
SRR-4563 | 100 | 108 | 1270 | 35 | 1284 | 1097 | |
SRR-4564 | 200 | 207 | 2575 | 35 | 2761 | 2558 |
This file contains 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
`simulate.gamm` <- function(object, nsim = 1, seed = NULL, newdata, | |
freq = FALSE, unconditional = FALSE, ...) { | |
if (!exists(".Random.seed", envir = .GlobalEnv, inherits = FALSE)) | |
runif(1) | |
if (is.null(seed)) | |
RNGstate <- get(".Random.seed", envir = .GlobalEnv) | |
else { | |
R.seed <- get(".Random.seed", envir = .GlobalEnv) | |
set.seed(seed) | |
RNGstate <- structure(seed, kind = as.list(RNGkind())) |
This file contains 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
genURLS <- function(id, start, end, timeframe = c("hourly", "daily", "monthly")) { | |
years <- seq(start, end, by = 1) | |
nyears <- length(years) | |
timeframe <- match.arg(timeframe) | |
if (isTRUE(all.equal(timeframe, "hourly"))) { | |
years <- rep(years, each = 12) | |
months <- rep(1:12, times = nyears) | |
ids <- rep(id, nyears * 12) | |
} else if (isTRUE(all.equal(timeframe, "daily"))) { | |
months <- 1 # this is essentially arbitrary & ignored if daily |
This file contains 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
`derivSimulCI` <- function(mod, n = 200, eps = 1e-7, newdata, term, | |
samples = 10000) { | |
stopifnot(require("MASS")) | |
if(inherits(mod, "gamm")) | |
mod <- mod$gam | |
m.terms <- attr(terms(mod), "term.labels") | |
if(missing(newdata)) { | |
newD <- sapply(model.frame(mod)[, m.terms, drop = FALSE], | |
function(x) seq(min(x), max(x) - (2*eps), length = n)) | |
names(newD) <- m.terms |
OlderNewer