added
This commit is contained in:
parent
d6b4106838
commit
f9b98a6306
44
freqdist.R
Normal file
44
freqdist.R
Normal file
@ -0,0 +1,44 @@
|
||||
library(tidyverse)
|
||||
library(DBI)
|
||||
|
||||
Sys.setenv(PGHOST = "db.mainscnt.eu",
|
||||
PGDATABASE = "mainscnt",
|
||||
PGPORT = 5432,
|
||||
PGUSER = "wn",
|
||||
PGSSLMODE = "verify-ca",
|
||||
PGSSLKEY = "/home/wn/keys/psql/wn-postgresql-client-2.pem",
|
||||
PGSSLCERT = "/home/wn/keys/psql/wn-postgresql-client-2.crt",
|
||||
PGSSLROOTCERT = "/home/wn/keys/psql/postgres-ca.crt")
|
||||
|
||||
|
||||
con <- dbConnect(RPostgres::Postgres())
|
||||
res <-dbSendQuery(con,
|
||||
'select time, freq, location
|
||||
from mainsfrequency
|
||||
where time >= \'2022-04-01 00:00:00\' and
|
||||
time < \'2022-04-05 00:00:00\' and
|
||||
valid = 1')
|
||||
freqs <- dbFetch(res)
|
||||
dbClearResult(res)
|
||||
dbDisconnect(con)
|
||||
|
||||
freqs <- as_tibble(freqs)
|
||||
freqs <- freqs %>%
|
||||
mutate(year = year(time), month = month(time), day = day(time)) %>%
|
||||
group_by(year, month, day)
|
||||
|
||||
# p = ggplot(data = freqs) +
|
||||
# geom_histogram(mapping = aes(x = freq))
|
||||
# print(p)
|
||||
|
||||
#p <- ggplot(data=freqs) +
|
||||
# geom_boxplot(mapping=aes(group=day,x=time,y=freq), na.rm=TRUE) +
|
||||
# scale_x_datetime("Date", breaks="1 day") +
|
||||
# scale_y_continuous("Frequency") +
|
||||
# theme(axis.text.x=element_text(angle=-90, vjust=0)) +
|
||||
# labs(title = "Mains Frequency deviation")
|
||||
|
||||
p <- ggplot(data= freqs) +
|
||||
geom_freqpoly(mapping = aes(x=freq, color=location))
|
||||
|
||||
print(p)
|
Loading…
x
Reference in New Issue
Block a user