Skip to content

Commit

Permalink
Replaced non-standard evaluation
Browse files Browse the repository at this point in the history
  • Loading branch information
xavierdidelot committed Sep 14, 2018
1 parent 724eb73 commit 94d8962
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
4 changes: 4 additions & 0 deletions .Rbuildignore
@@ -0,0 +1,4 @@
^.*\.Rproj$
^\.Rproj\.user$
^_config.yml$
^figure$
3 changes: 2 additions & 1 deletion DESCRIPTION
Expand Up @@ -10,4 +10,5 @@ License: MIT + file LICENSE
Imports: Rcpp (>= 0.12.10), RcppArmadillo, stats, graphics, ape
LinkingTo: Rcpp,RcppArmadillo
Suggests: ggplot2
RoxygenNote: 6.0.1
RoxygenNote: 6.1.0
Encoding: UTF-8
14 changes: 7 additions & 7 deletions R/skygrowth.R
Expand Up @@ -951,8 +951,8 @@ neplot.skygrowth.map <- function( fit, ggplot=TRUE, logy=TRUE, ... )
if ( 'ggplot2' %in% installed.packages() & ggplot)
{
pldf <- data.frame( t = fit$time, nemed = ne, nelb = fit$ne_ci[,1], neub = fit$ne_ci[,3] )
pl <- ggplot2::ggplot( pldf, ggplot2::aes( x = t, y = nemed) , ...) + ggplot2::geom_line()+ ggplot2::ylab('Effective population size') + ggplot2::xlab('Time before most recent sample')
pl <- pl + ggplot2::geom_ribbon( ggplot2::aes( ymin = nelb, ymax = neub), fill = 'blue', alpha = .2)
pl <- ggplot2::ggplot( pldf, ggplot2::aes_( x = ~ t, y = ~ nemed) , ...) + ggplot2::geom_line()+ ggplot2::ylab('Effective population size') + ggplot2::xlab('Time before most recent sample')
pl <- pl + ggplot2::geom_ribbon( ggplot2::aes_( ymin = ~ nelb, ymax = ~ neub), fill = 'blue', alpha = .2)
if (logy) pl <- pl + ggplot2::scale_y_log10()
return(pl)
} else{
Expand All @@ -972,7 +972,7 @@ growth.plot.skygrowth.map <- function( fit , ggplot=TRUE, logy=FALSE, ...)
if ( 'ggplot2' %in% installed.packages() & ggplot)
{
pldf <- data.frame( t = fit$time, gr = fit$growth)
pl <- ggplot2::ggplot( pldf, ggplot2::aes( x = t, y = gr), ... ) + ggplot2::geom_line() + ggplot2::ylab('Growth rate') + ggplot2::xlab('Time before most recent sample')
pl <- ggplot2::ggplot( pldf, ggplot2::aes_( x = ~ t, y = ~ gr), ... ) + ggplot2::geom_line() + ggplot2::ylab('Growth rate') + ggplot2::xlab('Time before most recent sample')
if (logy) pl <- pl + ggplot2::scale_y_log10()
return(pl)
} else{
Expand All @@ -995,7 +995,7 @@ R.plot.skygrowth.map <- function(fit, gamma = NA , ggplot=TRUE, ...)
{
i <- 1:(length(fit$time)-1)
pldf <- data.frame( t = fit$time[1:length(fit$R)],R = fit$R)
ggplot2::ggplot( pldf, ggplot2::aes( x = t, y = R) , ...) + ggplot2::geom_line() + ggplot2::ylab('Reproduction number') + ggplot2::xlab('Time before most recent sample')
ggplot2::ggplot( pldf, ggplot2::aes_( x = ~ t, y = ~ R) , ...) + ggplot2::geom_line() + ggplot2::ylab('Reproduction number') + ggplot2::xlab('Time before most recent sample')
} else{
plot( fit$time, fit$R, lwd =2, col = 'black', type = 'l',xlab='Time', ylab='Reproduction number', ...)
invisible(fit)
Expand All @@ -1015,7 +1015,7 @@ neplot.skygrowth.mcmc <- function( fit, ggplot=TRUE, logy = TRUE , ... )
if ( 'ggplot2' %in% installed.packages() & ggplot)
{
pldf <- data.frame( t = fit$time, nelb = ne[,1], nemed = ne[,2], neub = ne[,3] )
pl <- ggplot2::ggplot( pldf, ggplot2::aes( x = t, y = nemed), ... ) + ggplot2::geom_line() + ggplot2::geom_ribbon( ggplot2::aes( ymin = nelb, ymax = neub), fill = 'blue', alpha = .2) + ggplot2::ylab('Effective population size') + ggplot2::xlab('Time before most recent sample')
pl <- ggplot2::ggplot( pldf, ggplot2::aes_( x = ~ t, y = ~ nemed), ... ) + ggplot2::geom_line() + ggplot2::geom_ribbon( ggplot2::aes_( ymin = ~ nelb, ymax = ~ neub), fill = 'blue', alpha = .2) + ggplot2::ylab('Effective population size') + ggplot2::xlab('Time before most recent sample')
if (logy) pl <- pl + ggplot2::scale_y_log10()
return(pl)
} else{
Expand All @@ -1036,7 +1036,7 @@ growth.plot.skygrowth.mcmc <- function( fit , ggplot=TRUE, logy = FALSE , ...)
if ( 'ggplot2' %in% installed.packages() & ggplot)
{
pldf <- data.frame( t = fit$time, lb = x[,1], med = x[,2], ub = x[,3] )
pl <- ggplot2::ggplot( pldf, ggplot2::aes( x = t, y = med), ... ) + ggplot2::geom_line() + ggplot2::geom_ribbon( ggplot2::aes( ymin = lb, ymax = ub), fill = 'blue', alpha = .2) + ggplot2::ylab('Growth rate') + ggplot2::xlab('Time before most recent sample')
pl <- ggplot2::ggplot( pldf, ggplot2::aes_( x = ~ t, y = ~ med), ... ) + ggplot2::geom_line() + ggplot2::geom_ribbon( ggplot2::aes_( ymin = ~ lb, ymax = ~ ub), fill = 'blue', alpha = .2) + ggplot2::ylab('Growth rate') + ggplot2::xlab('Time before most recent sample')
if (logy) pl <- pl + ggplot2::scale_y_log10()
return(pl)
} else{
Expand All @@ -1063,7 +1063,7 @@ R.plot.skygrowth.mcmc <- function(fit, gamma = NA, ggplot=TRUE )


pldf <- data.frame( t = fit$time, lb = x[,1], med = x[,2], ub = x[,3] )
ggplot2::ggplot( pldf, ggplot2::aes( x = t, y = med) ) + ggplot2::geom_line() + ggplot2::geom_ribbon( ggplot2::aes( ymin = lb, ymax = ub), fill = 'blue', alpha = .2) + ggplot2::ylab('Reproduction number') + ggplot2::xlab('Time before most recent sample')
ggplot2::ggplot( pldf, ggplot2::aes_( x = ~ t, y = ~ med) ) + ggplot2::geom_line() + ggplot2::geom_ribbon( ggplot2::aes_( ymin = ~ lb, ymax = ~ ub), fill = 'blue', alpha = .2) + ggplot2::ylab('Reproduction number') + ggplot2::xlab('Time before most recent sample')
} else{
plot( fit$time, x[,2], ylim=range(x[,1:3],na.rm=T),lwd =2, col = 'black', type = 'l',xlab='Time', ylab='Reproduction number')

Expand Down
4 changes: 2 additions & 2 deletions man/skygrowth.mcmc.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 94d8962

Please sign in to comment.