Compare commits

..

No commits in common. "2d9aa5d1cdac25f5a92e03d8afb8f4420a66d4d7" and "fa69fe9c5f025ec077c1d6c453db54d352a23102" have entirely different histories.

2 changed files with 19 additions and 3 deletions

12
main.go
View File

@ -56,7 +56,7 @@ func getConf() Config {
if err != nil { if err != nil {
log.Fatal("Error creating R source file: ", err) log.Fatal("Error creating R source file: ", err)
} }
_, err = of.WriteString(rCode) _, err = of.WriteString(rCode())
if err != nil { if err != nil {
log.Fatal("Error writing R source code: ", err) log.Fatal("Error writing R source code: ", err)
} }
@ -99,6 +99,16 @@ func fetch() {
log.Printf("Length differs: body = %d", len(body)) log.Printf("Length differs: body = %d", len(body))
conf.Len = int64(len(body)) conf.Len = int64(len(body))
save() save()
of, err := os.Create(path.Join(path.Dir(confFile), "rows.csv"))
if err != nil {
log.Fatal("Cannot create rows.csv: ", err)
}
_, err = of.Write(body)
if err != nil {
log.Fatal("Error writing rows.csv: ", err)
}
confDir := path.Dir(confFile) confDir := path.Dir(confFile)
cmd := exec.Command("R", "--no-save", "-f", path.Join(confDir, "c.R")) cmd := exec.Command("R", "--no-save", "-f", path.Join(confDir, "c.R"))
log.Printf("Running R") log.Printf("Running R")

View File

@ -1,6 +1,11 @@
package main package main
var rCode string = ` import (
"path"
)
func rCode() string {
return `
library(tidyverse) library(tidyverse)
library(ggplot2) library(ggplot2)
library(gridExtra) library(gridExtra)
@ -10,7 +15,7 @@ gc()
options(scipen=100000) options(scipen=100000)
d <- read_csv('~/prog/covid/nyopendata/rows.csv') d <- read_csv('`+ path.Dir(confFile) + `/rows.csv')
d <- pivot_longer(d, c('New Positives', 'Total Number of Tests Performed')) d <- pivot_longer(d, c('New Positives', 'Total Number of Tests Performed'))
d <- transmute(d, date=mdy(d$'Test Date'), county=County, name=name, value=value) d <- transmute(d, date=mdy(d$'Test Date'), county=County, name=name, value=value)
queens <- subset(d, county=='Queens') queens <- subset(d, county=='Queens')
@ -34,3 +39,4 @@ zip <- read_csv('~/prog/covid/nyopendata/timeseries.csv')
zip <- pivot_longer(zip, c('COVID_CASE_COUNT','COVID_DEATH_COUNT','TOTAL_COVID_TESTS')) zip <- pivot_longer(zip, c('COVID_CASE_COUNT','COVID_DEATH_COUNT','TOTAL_COVID_TESTS'))
zip$date <- mdy(zip$date) zip$date <- mdy(zip$date)
` `
}