-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathglobal.R
67 lines (52 loc) · 1.52 KB
/
global.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# Application de visualisation de la consommation de médicaments
library(shiny)
library(grid)
library(gridExtra)
library(plyr)
library(Cairo)
library(ggplot2)
library(plotly)
library(scales)
library(data.table)
library(pool)
library(RPostgreSQL)
library(glue)
library(askpass)
library(XML)
library(RCurl)
library(xlsx)
options(digits = 4, scipen=999)
options(encoding = 'utf-8')
### Fonction
set_utf8 <- function(x) {
chr = sapply(x, is.character)
x[, chr] = lapply(x[, chr, drop = FALSE], `Encoding<-`, "UTF-8")
Encoding(names(x)) = "UTF-8"
x
}
#### Connexion à postgres
configuration = readLines("config.txt")
con <- dbPool(
drv = dbDriver("PostgreSQL", max.con = 100),
dbname = "medicaments",
host = "localhost",
user = configuration[1],
password = configuration[2],
idleTimeout = 900 # 15 minutes
)
rm(configuration)
#lapply(dbListConnections(PostgreSQL()), dbDisconnect)
# Choix du menu déroulant de la spécialité
tousCIP = dbGetQuery(con,
"SELECT DISTINCT denomination from referentiel
ORDER BY denomination ;")
tousCIP = set_utf8(tousCIP)
tousCIP = tousCIP$denomination
tousCIP = tousCIP[!is.na(tousCIP)]
denominationProduit <<- tousCIP[1]
# Mois disponibles - on pre
listeMois = dbGetQuery(con, "SELECT DISTINCT mois from consommation
ORDER BY mois;")$mois
ccp = read.csv('./data/importbdd/ccp.csv', stringsAsFactors = F)
# Texte de la faq
faq = readLines('faq.html')