Skip to content

Commit

Permalink
grafici vari
Browse files Browse the repository at this point in the history
  • Loading branch information
Gianluca124 committed Jan 5, 2023
1 parent e0833b2 commit f045807
Show file tree
Hide file tree
Showing 3 changed files with 849 additions and 60 deletions.
67 changes: 66 additions & 1 deletion Analisi esplorative/esplorazione_ristorante1.R
Original file line number Diff line number Diff line change
Expand Up @@ -669,4 +669,69 @@ mean_scontrino$mean_val[1] - mean_scontrino$mean_val[2]

# Varianza pre/post

var_scontrino
var_scontrino

# Grafico colori regioni

trend <- read.csv("..//Dati ristoranti//trend.csv", header = FALSE)
trend <- head(trend, -2)

ris1_postcovid <- copy_ristorante1[copy_ristorante1$data > "2020-05-06", c("lordototale", "data", "ColoreCOVID")]
ris1_postcovid$lordototale[ris1_postcovid$lordototale == 0] <- NA
ris1_postcovid$lordototale <- na_kalman(ris1_postcovid$lordototale)
ris1_postcovid <- head(ris1_postcovid, -2)
graph_ts <- xts(ris1_postcovid[, c("lordototale")], as.Date(as.character(ris1_postcovid$data), format = "%Y-%m-%d"))

ris1_postcovid = cbind(ris1_postcovid, trend$V2)

date_red <- c("2020-11-06", "2020-11-28", "2020-12-24", "2020-12-27", "2020-12-31", "2021-01-06",
"2021-01-17", "2021-01-23", "2021-03-15" ,"2021-04-11")
date_arancio <- c("2020-11-29", "2020-12-12", "2020-12-28", "2020-12-30", "2021-01-09", "2021-01-16",
"2021-01-24", "2021-01-31", "2021-03-01" ,"2021-03-14", "2021-04-12", "2021-04-25")
date_giallo <- c("2020-12-13", "2020-12-23", "2021-01-07", "2021-01-08", "2021-02-01", "2021-02-28",
"2021-04-26", "2021-06-13", "2022-01-03", "2022-02-27")

# Color manipulation

t_col <- function(color, percent = 50, name = NULL) {
# color = color name
# percent = % transparency
# name = an optional name for the color

## Get RGB values for named color
rgb.val <- col2rgb(color)

## Make new color using input color as base and alpha set by transparency
t.col <- rgb(rgb.val[1], rgb.val[2], rgb.val[3],
max = 255,
alpha = (100 - percent) * 255 / 100,
names = name)

## Save the color
invisible(t.col)
}

red.rgb.val <- col2rgb("red")
my_red <- adjustcolor("red", alpha.f = 0.2)

ggplot(data=ris1_postcovid, aes(x=data)) +
geom_rect(data=NULL, aes(xmin=as.Date(date_red[1], "%Y-%m-%d"), xmax=as.Date(date_red[2], "%Y-%m-%d"), ymin=-Inf, ymax=Inf), fill="red", alpha = .15) +
geom_rect(data=NULL, aes(xmin=as.Date(date_red[3], "%Y-%m-%d"), xmax=as.Date(date_red[4], "%Y-%m-%d"), ymin=-Inf, ymax=Inf), fill="red", alpha = .15) +
geom_rect(data=NULL, aes(xmin=as.Date(date_red[5], "%Y-%m-%d"), xmax=as.Date(date_red[6], "%Y-%m-%d"), ymin=-Inf, ymax=Inf), fill="red", alpha = .15) +
geom_rect(data=NULL, aes(xmin=as.Date(date_red[7], "%Y-%m-%d"), xmax=as.Date(date_red[8], "%Y-%m-%d"), ymin=-Inf, ymax=Inf), fill="red", alpha = .15) +
geom_rect(data=NULL, aes(xmin=as.Date(date_red[9], "%Y-%m-%d"), xmax=as.Date(date_red[10], "%Y-%m-%d"), ymin=-Inf, ymax=Inf), fill=my_red) +
geom_rect(data=NULL, aes(xmin=as.Date(date_arancio[1], "%Y-%m-%d"), xmax=as.Date(date_arancio[2], "%Y-%m-%d"), ymin=-Inf, ymax=Inf), fill="orange", alpha = .15) +
geom_rect(data=NULL, aes(xmin=as.Date(date_arancio[3], "%Y-%m-%d"), xmax=as.Date(date_arancio[4], "%Y-%m-%d"), ymin=-Inf, ymax=Inf), fill="orange", alpha = .15) +
geom_rect(data=NULL, aes(xmin=as.Date(date_arancio[5], "%Y-%m-%d"), xmax=as.Date(date_arancio[6], "%Y-%m-%d"), ymin=-Inf, ymax=Inf), fill="orange", alpha = .15) +
geom_rect(data=NULL, aes(xmin=as.Date(date_arancio[7], "%Y-%m-%d"), xmax=as.Date(date_arancio[8], "%Y-%m-%d"), ymin=-Inf, ymax=Inf), fill="orange", alpha = .15) +
geom_rect(data=NULL, aes(xmin=as.Date(date_arancio[9], "%Y-%m-%d"), xmax=as.Date(date_arancio[10], "%Y-%m-%d"), ymin=-Inf, ymax=Inf), fill="orange", alpha = .15) +
geom_rect(data=NULL, aes(xmin=as.Date(date_arancio[11], "%Y-%m-%d"), xmax=as.Date(date_arancio[12], "%Y-%m-%d"), ymin=-Inf, ymax=Inf), fill="orange", alpha = .15) +
geom_rect(data=NULL, aes(xmin=as.Date(date_giallo[1], "%Y-%m-%d"), xmax=as.Date(date_giallo[2], "%Y-%m-%d"), ymin=-Inf, ymax=Inf), fill="yellow", alpha = .15) +
geom_rect(data=NULL, aes(xmin=as.Date(date_giallo[3], "%Y-%m-%d"), xmax=as.Date(date_giallo[4], "%Y-%m-%d"), ymin=-Inf, ymax=Inf), fill="yellow", alpha = .15) +
geom_rect(data=NULL, aes(xmin=as.Date(date_giallo[5], "%Y-%m-%d"), xmax=as.Date(date_giallo[6], "%Y-%m-%d"), ymin=-Inf, ymax=Inf), fill="yellow", alpha = .15) +
geom_rect(data=NULL, aes(xmin=as.Date(date_giallo[7], "%Y-%m-%d"), xmax=as.Date(date_giallo[8], "%Y-%m-%d"), ymin=-Inf, ymax=Inf), fill="yellow", alpha = .15) +
geom_rect(data=NULL, aes(xmin=as.Date(date_giallo[9], "%Y-%m-%d"), xmax=as.Date(date_giallo[10], "%Y-%m-%d"), ymin=-Inf, ymax=Inf), fill="yellow", alpha = .15) +
geom_line(aes(y = lordototale), color = "darkgrey") +
geom_line(aes(y = trend$V2), color = "black", size = 1) +
theme_bw() +
ggtitle("Andamento serie storica post lockdown") + ylab("Vendite") + xlab("Data")
118 changes: 59 additions & 59 deletions Dati ristoranti/previsioni_RF_future.csv
Original file line number Diff line number Diff line change
@@ -1,61 +1,61 @@
"","V1"
"1",17918.348625
"2",25394.158125
"3",20921.463
"4",16632.486
"5",12949.9695
"6",13125.375
"7",14270.571
"8",17437.5135
"9",25404.8454
"10",23795.21205
"11",15336.135
"12",12710.179125
"13",13421.446875
"14",14182.1118
"15",17401.9365
"16",25396.4808
"17",22550.5233
"18",13050.2385
"19",12458.9097
"20",13139.8659
"21",13625.901
"22",17779.19895
"23",26155.402875
"24",23719.293
"25",12910.5009
"26",12315.84075
"27",13036.3965
"28",13333.005
"29",17790.7995
"30",25728.9507
"31",23665.176
"32",12607.0587
"33",12327.63975
"34",12910.27275
"35",13540.3056
"36",17987.3487
"37",25848.676125
"38",23844.6423
"39",12106.7325
"40",12312.612
"41",12897.911475
"42",13380.348375
"43",18044.03655
"44",25741.506375
"45",23801.6907
"46",12221.8065
"47",12336.642
"48",12897.911475
"49",13447.84275
"50",18054.8487
"1",17853.6627
"2",24979.550175
"3",21084.7725
"4",16597.341
"5",13000.3461
"6",13081.815
"7",14151.7575
"8",17007.9237
"9",25411.586625
"10",23694.4116
"11",13668.669
"12",12460.408875
"13",13013.652375
"14",13755.8025
"15",17747.901
"16",25346.8764
"17",22572.459
"18",12742.002
"19",12338.48025
"20",12948.055875
"21",13302.468
"22",17760.33
"23",25766.5194
"24",23694.82065
"25",12511.6785
"26",12340.26225
"27",12839.171625
"28",13066.38
"29",17738.829225
"30",25652.8053
"31",23578.09155
"32",11427.21675
"33",12390.948
"34",12685.7421
"35",13188.3075
"36",17960.7996
"37",25732.134
"38",23735.079675
"39",11430.2781
"40",12335.3415
"41",12547.841625
"42",13015.819125
"43",18041.7015
"44",25782.22305
"45",23803.902
"46",11214.585
"47",12411.1035
"48",12536.073
"49",13142.347875
"50",18066.4551
"51",25732.134
"52",23821.4385
"53",11987.1225
"54",12328.875
"55",12926.7378
"56",13467.8511
"57",18058.9635
"58",25737.679125
"59",23798.3454
"60",12075.129
"52",23827.257
"53",11272.0995
"54",12366.7605
"55",12499.6149
"56",13182.27075
"57",18115.9551
"58",25732.134
"59",23806.4427
"60",11220.7707
Loading

0 comments on commit f045807

Please sign in to comment.