changes
This commit is contained in:
28
freqdist.R
28
freqdist.R
@ -1,14 +1,16 @@
|
|||||||
library(tidyverse)
|
library(tidyverse)
|
||||||
|
library(lubridate, warn.conflicts=FALSE)
|
||||||
library(DBI)
|
library(DBI)
|
||||||
|
|
||||||
|
HOME <- Sys.getenv("HOME")
|
||||||
Sys.setenv(PGHOST = "db.mainscnt.eu",
|
Sys.setenv(PGHOST = "db.mainscnt.eu",
|
||||||
PGDATABASE = "mainscnt",
|
PGDATABASE = "mainscnt",
|
||||||
PGPORT = 5432,
|
PGPORT = 5432,
|
||||||
PGUSER = "wn",
|
PGUSER = "wn",
|
||||||
PGSSLMODE = "verify-ca",
|
PGSSLMODE = "verify-ca",
|
||||||
PGSSLKEY = "/home/wn/keys/psql/wn-postgresql-client-2.pem",
|
PGSSLKEY = paste(HOME, "/keys/psql/wn-postgresql-client-2.key", sep=""),
|
||||||
PGSSLCERT = "/home/wn/keys/psql/wn-postgresql-client-2.crt",
|
PGSSLCERT = paste(HOME, "/keys/psql/wn-postgresql-client-2.crt", sep=""),
|
||||||
PGSSLROOTCERT = "/home/wn/keys/psql/postgres-ca.crt")
|
PGSSLROOTCERT = paste(HOME, "/keys/psql/postgres-ca.crt", sep=""))
|
||||||
|
|
||||||
|
|
||||||
con <- dbConnect(RPostgres::Postgres())
|
con <- dbConnect(RPostgres::Postgres())
|
||||||
@ -16,7 +18,8 @@ res <-dbSendQuery(con,
|
|||||||
'select time, freq, location
|
'select time, freq, location
|
||||||
from mainsfrequency
|
from mainsfrequency
|
||||||
where time >= \'2022-04-01 00:00:00\' and
|
where time >= \'2022-04-01 00:00:00\' and
|
||||||
time < \'2022-04-05 00:00:00\' and
|
time < \'2022-05-01 00:00:00\' and
|
||||||
|
location != \'Nsawam_GH\' and
|
||||||
valid = 1')
|
valid = 1')
|
||||||
freqs <- dbFetch(res)
|
freqs <- dbFetch(res)
|
||||||
dbClearResult(res)
|
dbClearResult(res)
|
||||||
@ -24,6 +27,7 @@ dbDisconnect(con)
|
|||||||
|
|
||||||
freqs <- as_tibble(freqs)
|
freqs <- as_tibble(freqs)
|
||||||
freqs <- freqs %>%
|
freqs <- freqs %>%
|
||||||
|
filter(freq > 49.6 & freq < 50.4, na.rm=TRUE) %>%
|
||||||
mutate(year = year(time), month = month(time), day = day(time)) %>%
|
mutate(year = year(time), month = month(time), day = day(time)) %>%
|
||||||
group_by(year, month, day)
|
group_by(year, month, day)
|
||||||
|
|
||||||
@ -31,14 +35,14 @@ freqs <- freqs %>%
|
|||||||
# geom_histogram(mapping = aes(x = freq))
|
# geom_histogram(mapping = aes(x = freq))
|
||||||
# print(p)
|
# print(p)
|
||||||
|
|
||||||
#p <- ggplot(data=freqs) +
|
p <- ggplot(data=freqs) +
|
||||||
# geom_boxplot(mapping=aes(group=day,x=time,y=freq), na.rm=TRUE) +
|
geom_boxplot(mapping=aes(group=day,x=time,y=freq), na.rm=TRUE) +
|
||||||
# scale_x_datetime("Date", breaks="1 day") +
|
scale_x_datetime("Date", breaks="1 day") +
|
||||||
# scale_y_continuous("Frequency") +
|
scale_y_continuous("Frequency", n.breaks=7) +
|
||||||
# theme(axis.text.x=element_text(angle=-90, vjust=0)) +
|
theme(axis.text.x=element_text(angle=-90, vjust=0)) +
|
||||||
# labs(title = "Mains Frequency deviation")
|
labs(title = "Mains Frequency deviation")
|
||||||
|
|
||||||
p <- ggplot(data= freqs) +
|
#p <- ggplot(data= freqs) +
|
||||||
geom_freqpoly(mapping = aes(x=freq, color=location))
|
# geom_freqpoly(mapping = aes(x=freq, color=location))
|
||||||
|
|
||||||
print(p)
|
print(p)
|
||||||
|
Reference in New Issue
Block a user