Last active
August 29, 2015 14:18
-
-
Save SimonGoring/2220586c4cedaf1f554c to your computer and use it in GitHub Desktop.
Figure out the age control by year data for Neotoma.
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
library(neotoma) | |
library(reshape2) | |
pollen_data <- get_dataset(datasettype= 'pollen') | |
full_records <- get_download(pollen_data) # this takes a bit of time | |
pub.dates <- get_publication(pollen.data) # so does this | |
earliest.year <- do.call(rbind.data.frame, | |
lapply(pub.dates, function(x)data.frame(id = NA, | |
year = min(sapply(x, function(y)y$meta$year))))) | |
earliest.year$id <- sapply(pollen.data, function(x) x$dataset$dataset.meta$dataset.id) | |
aa <- lapply(full_records, function(x){ | |
control.table <- try(get_chroncontrol(x$sample.meta$chronology.id[1])$chron.control$control.type) | |
if(!class(control.table) == 'try-error'){ | |
output <- data.frame(control = as.character(control.table), id = x$dataset$dataset.meta$dataset.id) | |
} else { | |
output <- data.frame(control = NA, id = NA) | |
} | |
output}) | |
chron.table <- do.call(rbind.data.frame, aa) | |
chron.table$year <- earliest.year$year[match(chron.table$id, earliest.year$id)] | |
model.table <- dcast(chron.table, formula = control~year, length) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's because it should be pulling from
full_data
, not thepollen_data
that's getting pulled. That's my mistake.