Skip to content

Instantly share code, notes, and snippets.

@SimonGoring
Created June 4, 2015 20:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SimonGoring/02542be8842c4e476a68 to your computer and use it in GitHub Desktop.
Save SimonGoring/02542be8842c4e476a68 to your computer and use it in GitHub Desktop.
Rate of data upload to Neotoma: 2014 - present
library(neotoma)
library(ggplot2)
library(reshape2)
ds_upload <- get_dataset()
subyr <- lapply(ds_upload, function(x){
if(nrow(x$submission) == 0){
subdate <- NA
} else {
subdate <- x$submission[nrow(x$submission),1]
}
data.frame(subdate, type = x$dataset.meta$dataset.type)
})
subyr <-do.call(rbind.data.frame, subyr)
subyr$subdate.mo <- as.Date(paste0(substr(subyr$subdate, 1,7),'-01'), format = '%Y-%m-%d')
sub_subyr <- subset(subyr, as.numeric(as.Date(subdate.mo)) > as.numeric(as.Date('2013-01-01')))
sub_case <- melt(dcast(sub_subyr, type ~ subdate.mo, fun.aggregate = length))
sub_subyr$type <- factor(sub_subyr$type)
upload.plot <- ggplot(sub_subyr, aes(x = subdate.mo, fill = type)) + geom_bar(binwidth=30) +
theme_bw() + xlab('Date of Inclusion in Neotoma') + ylab('Number of Records') +
theme(axis.text = element_text(family='serif', size = 12),
axis.title = element_text(family='serif', face='bold', size = 18),
legend.title = element_text(family='serif', face='bold', size = 16)) +
scale_fill_discrete(name = 'Dataset Type') +
scale_x_date(expand = c(0,0))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment