Change scale on positivity plots. Do not exit if R command fails.

This commit is contained in:
Greg 2020-11-30 21:19:06 -05:00
parent 9084506abd
commit 44e475e67e
2 changed files with 6 additions and 5 deletions

View File

@ -118,7 +118,8 @@ func fetch() {
log.Printf("Running R") log.Printf("Running R")
err = cmd.Run() err = cmd.Run()
if err != nil { if err != nil {
log.Fatal("Error running R: ", err) log.Print("Error running R: ", err)
return
} }
log.Printf("R completed") log.Printf("R completed")
if conf.MailHost == "" { if conf.MailHost == "" {

View File

@ -27,8 +27,8 @@ d2 <- rbind(queens, totals)
p1 <- ggplot(queens, aes(x=date, y=value, group=name, color=name))+geom_line(color='black',alpha=1/3)+scale_y_log10(n.breaks=6, position='right')+labs(y='',color='')+ggtitle('Queens')+theme(plot.title=element_text(hjust = 0.5))+theme(legend.position='bottom')+geom_smooth(se=FALSE,method='gam') p1 <- ggplot(queens, aes(x=date, y=value, group=name, color=name))+geom_line(color='black',alpha=1/3)+scale_y_log10(n.breaks=6, position='right')+labs(y='',color='')+ggtitle('Queens')+theme(plot.title=element_text(hjust = 0.5))+theme(legend.position='bottom')+geom_smooth(se=FALSE,method='gam')
p2 <- ggplot(totals, aes(x=date, y=value, group=name, color=name))+geom_line(color='black',alpha=1/3)+stat_smooth(geom='line', linetype='dotted', method='gam', se=FALSE)+scale_y_log10(n.breaks=6, position='right')+labs(y='')+labs(color='')+ggtitle('New York')+theme(plot.title=element_text(hjust = 0.5))+theme(legend.position='bottom')+geom_smooth(se=FALSE,method='gam') p2 <- ggplot(totals, aes(x=date, y=value, group=name, color=name))+geom_line(color='black',alpha=1/3)+stat_smooth(geom='line', linetype='dotted', method='gam', se=FALSE)+scale_y_log10(n.breaks=6, position='right')+labs(y='')+labs(color='')+ggtitle('New York')+theme(plot.title=element_text(hjust = 0.5))+theme(legend.position='bottom')+geom_smooth(se=FALSE,method='gam')
pr1 <- ggplot(qrate, aes(x=date, y=value)) + geom_line(color='black',alpha=1/3)+geom_smooth(method='gam',formula=y~s(x, bs="cs"),se=FALSE)+scale_y_continuous(labels = scales::percent, position='right')+labs(y='Positive Rate')+coord_cartesian(ylim=c(0,0.04))+ggtitle('Queens')+theme(plot.title=element_text(hjust = 0.5)) pr1 <- ggplot(qrate, aes(x=date, y=value)) + geom_line(color='black',alpha=1/3)+geom_smooth(method='gam',formula=y~s(x, bs="cs"),se=FALSE)+scale_y_continuous(labels = scales::percent, position='right')+labs(y='Positive Rate')+coord_cartesian(ylim=c(0,0.05))+ggtitle('Queens')+theme(plot.title=element_text(hjust = 0.5))
pr2 <- ggplot(trate, aes(x=date, y=value)) + geom_line(color='black',alpha=1/3)+geom_smooth(method='gam',formula=y~s(x, bs="cs"),se=FALSE)+scale_y_continuous(labels = scales::percent, position='right')+labs(y='Positive Rate')+coord_cartesian(ylim=c(0,0.04))+ggtitle('New York')+theme(plot.title=element_text(hjust = 0.5)) pr2 <- ggplot(trate, aes(x=date, y=value)) + geom_line(color='black',alpha=1/3)+geom_smooth(method='gam',formula=y~s(x, bs="cs"),se=FALSE)+scale_y_continuous(labels = scales::percent, position='right')+labs(y='Positive Rate')+coord_cartesian(ylim=c(0,0.05))+ggtitle('New York')+theme(plot.title=element_text(hjust = 0.5))
queens <- tail(queens,n=32) queens <- tail(queens,n=32)
totals <- tail(totals,n=32) totals <- tail(totals,n=32)
@ -38,9 +38,9 @@ trate <- tail(trate,n=16)
p3 <- ggplot(queens, aes(x=date, y=value, color=name))+geom_line()+scale_y_log10(n.breaks=12, position='right')+labs(y='',color='')+ggtitle('Queens')+theme(plot.title=element_text(hjust = 0.5))+theme(legend.position='bottom') p3 <- ggplot(queens, aes(x=date, y=value, color=name))+geom_line()+scale_y_log10(n.breaks=12, position='right')+labs(y='',color='')+ggtitle('Queens')+theme(plot.title=element_text(hjust = 0.5))+theme(legend.position='bottom')
p4 <- ggplot(totals, aes(x=date, y=value, color=name))+geom_line()+scale_y_log10(n.breaks=12, position='right')+labs(y='')+labs(color='')+ggtitle('New York')+theme(plot.title=element_text(hjust = 0.5))+theme(legend.position='bottom') p4 <- ggplot(totals, aes(x=date, y=value, color=name))+geom_line()+scale_y_log10(n.breaks=12, position='right')+labs(y='')+labs(color='')+ggtitle('New York')+theme(plot.title=element_text(hjust = 0.5))+theme(legend.position='bottom')
pr3 <- ggplot(qrate, aes(x=date, y=value)) + geom_line()+scale_y_continuous(labels = scales::percent, position='right')+labs(y='Positive Rate')+coord_cartesian(ylim=c(0,0.04))+ggtitle('Queens')+theme(plot.title=element_text(hjust = 0.5)) pr3 <- ggplot(qrate, aes(x=date, y=value)) + geom_line()+scale_y_continuous(labels = scales::percent, position='right')+labs(y='Positive Rate')+coord_cartesian(ylim=c(0,0.05))+ggtitle('Queens')+theme(plot.title=element_text(hjust = 0.5))
pr4 <- ggplot(trate, aes(x=date, y=value)) + geom_line()+scale_y_continuous(labels = scales::percent, position='right')+labs(y='Positive Rate')+coord_cartesian(ylim=c(0,0.04))+ggtitle('New York')+theme(plot.title=element_text(hjust = 0.5)) pr4 <- ggplot(trate, aes(x=date, y=value)) + geom_line()+scale_y_continuous(labels = scales::percent, position='right')+labs(y='Positive Rate')+coord_cartesian(ylim=c(0,0.05))+ggtitle('New York')+theme(plot.title=element_text(hjust = 0.5))
svg(width=8,height=16) svg(width=8,height=16)
grid.arrange(p1, p2, pr1, pr2, p3, p4, pr3, pr4, ncol=2, top=format(d[[nrow(d),1]], "%B %d %Y")) grid.arrange(p1, p2, pr1, pr2, p3, p4, pr3, pr4, ncol=2, top=format(d[[nrow(d),1]], "%B %d %Y"))