Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
giocoal committed Jan 3, 2023
2 parents b34e259 + f34037c commit 54f1723
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 20 deletions.
10 changes: 8 additions & 2 deletions Analisi esplorative/esplorazione.R
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,10 @@ p <- ggplot(ristoranti_ts,
aes(x = weeks,
y = value,
col = variable)) + geom_line()
p + labs(x = "data", y='lordototale')
p + labs(x = "Data", y='Vendite') +
theme(legend.title = element_blank(),
legend.position = c(0.045, 0.825),
legend.background = element_rect(fill = "white", color = "black"))

# Serie storica per ristorante (PRE-COVID)

Expand All @@ -544,4 +547,7 @@ p <- ggplot(ristoranti_ts_covid,
aes(x = weeks,
y = value,
col = variable)) + geom_line()
p + labs(x = "data", y='lordototale')
p + labs(x = "Data", y='Vendite') +
theme(legend.title = element_blank(),
legend.position = c(0.045, 0.825),
legend.background = element_rect(fill = "white", color = "black"))
67 changes: 53 additions & 14 deletions Analisi esplorative/esplorazione_ristorante1.R
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,16 @@ copy_ristorante1$Pandemia <- as.factor(copy_ristorante1$Pandemia)
### Giorno della settimana
ggplot(copy_ristorante1, aes(Giorno, lordototale, fill=Pandemia)) + geom_boxplot() +
theme_bw() +
xlab("") +
ylab("Vendite") +
ggtitle("Box-plot vendite per giorno della settimana") +
theme(strip.placement = "outside",
strip.background = element_blank(),
panel.grid.minor.x = element_blank(),
panel.border = element_rect(colour="grey70"),
panel.spacing=unit(0,"cm"))
panel.spacing=unit(0,"cm"),
legend.position = c(0.06, 0.9),
legend.background = element_rect(fill = "white", color = "black"))

ggplot(copy_ristorante1, aes(Giorno, scontrini, fill=Pandemia)) + geom_boxplot() +
theme_bw() +
Expand Down Expand Up @@ -170,12 +174,15 @@ ggplot(copy_ristorante1, aes(Season, scontrini, fill=Pandemia)) + geom_boxplot()
### Weekend/settimana (il venerd? ? considerato giorno della settimana)
ggplot(copy_ristorante1, aes(Weekend, lordototale, fill=Pandemia)) + geom_boxplot() +
theme_bw() +
ylab("Vendite") +
ggtitle("Box-plot vendite weekend vs. resto della settimana") +
theme(strip.placement = "outside",
strip.background = element_blank(),
panel.grid.minor.x = element_blank(),
panel.border = element_rect(colour="grey70"),
panel.spacing=unit(0,"cm"))
panel.spacing=unit(0,"cm"),
legend.position = c(0.06, 0.9),
legend.background = element_rect(fill = "white", color = "black"))

ggplot(copy_ristorante1, aes(Weekend, scontrini, fill=Pandemia)) + geom_boxplot() +
theme_bw() +
Expand All @@ -189,12 +196,15 @@ ggplot(copy_ristorante1, aes(Weekend, scontrini, fill=Pandemia)) + geom_boxplot(
### Giorno feriale vs. festivo
ggplot(copy_ristorante1, aes(Festivo, lordototale, fill=Pandemia)) + geom_boxplot() +
theme_bw() +
ylab("Vendite") +
ggtitle("Box-plot vendite giorno festivo vs. feriale") +
theme(strip.placement = "outside",
strip.background = element_blank(),
panel.grid.minor.x = element_blank(),
panel.border = element_rect(colour="grey70"),
panel.spacing=unit(0,"cm"))
panel.spacing=unit(0,"cm"),
legend.position = c(0.06, 0.9),
legend.background = element_rect(fill = "white", color = "black"))

ggplot(copy_ristorante1, aes(Festivo, scontrini, fill=Pandemia)) + geom_boxplot() +
theme_bw() +
Expand All @@ -208,12 +218,15 @@ ggplot(copy_ristorante1, aes(Festivo, scontrini, fill=Pandemia)) + geom_boxplot(
### Pioggia si/no
ggplot(copy_ristorante1, aes(Pioggia, lordototale, fill=Pandemia)) + geom_boxplot() +
theme_bw() +
ylab("Vendite") +
ggtitle("Box-plot vendite giorni di pioggia") +
theme(strip.placement = "outside",
strip.background = element_blank(),
panel.grid.minor.x = element_blank(),
panel.border = element_rect(colour="grey70"),
panel.spacing=unit(0,"cm"))
panel.spacing=unit(0,"cm"),
legend.position = c(0.06, 0.9),
legend.background = element_rect(fill = "white", color = "black"))

ggplot(copy_ristorante1, aes(Pioggia, scontrini, fill=Pandemia)) + geom_boxplot() +
theme_bw() +
Expand Down Expand Up @@ -445,15 +458,15 @@ vendite1_sett_avg <- ts(vendite1_sett_avg, start = decimal_date(as.Date("2018-01

print(
ggseasonplot(vendite1_mens_avg, year.labels=TRUE, year.labels.left=TRUE) +
ylab("euro") +
ggtitle("Seasonal plot Ristorante 1: vendite mensili")
ylab("Vendite") +
ggtitle("Seasonal plot: vendite mensili")
)

### Seasonal sub series plot
print(
ggsubseriesplot(vendite1_mens_avg) +
ylab("euro") +
ggtitle("Seasonal subseries plot Ristorante 1: vendite medie mensili"))
ylab("Vendite") +
ggtitle("Seasonal subseries plot - serie storica completa"))


### Stagionalit? considerando il periodo pre-COVID
Expand All @@ -474,26 +487,29 @@ print(

print(
ggsubseriesplot(pre_covid_1_mens_avg) +
ylab("euro") +
ggtitle("Seasonal subseries plot Ristorante 1: vendite medie mensili pre-COVID")
ylab("Vendite") +
ggtitle("Seasonal subseries plot - periodo pre-Covid")
)


### Analisi correlazione tra vendite e scontrini

scon_vend_sett_avg_1 <- ts.intersect(vendite1_sett_avg, scontrini1_sett_avg)
colnames(scon_vend_sett_avg_1) <- c('Vendite medie settimanali', 'Scontrini medi settimanali')

print(
autoplot(scon_vend_sett_avg_1, facets=TRUE) +
xlab("Anni") + ylab("") +
ggtitle("Confronto scontrini e vendite Ristorante 1")
xlab("") + ylab("") +
ggtitle("Confronto andamento vendite e scontrini")
)

print(
qplot(lordototale, scontrini, data=as.data.frame(copy_ristorante1), color=factor(Pandemia)) +
scale_colour_manual(values = c("red","blue"), name="Pandemia") +
ylab("Scontrini") + xlab("Vendite")+
ggtitle("Correlazione scontrini e vendite Ristorante 1")
ggtitle("Correlazione vendite e scontrini") +
theme(legend.position = c(0.94, 0.1),
legend.background = element_rect(fill = "white", color = "black"))
)

# Ho usato la copia senza dati aggregati mensilmente
Expand Down Expand Up @@ -642,7 +658,9 @@ p <- ggplot(df_scontrino_medio_no_out, aes(x = data, y = Prezzo_medio_per_scontr
# + stat_smooth(color = "#FC4E07", fill = "#FC4E07", method = "loess") aggiunge una sorta di trend
print(
p + theme(axis.text.x = element_text(angle = 90, vjust = 0.5, size = 8)) +
ggtitle("Ristorante 1: confronto scontrino medio pre/post COVID")
ggtitle("Confronto scontrino medio") + ylab("Prezzo medio per scontrino") + xlab(" ") +
theme(legend.position = c(0.95, 0.1),
legend.background = element_rect(fill = "white", color = "black"))
)

# Valuto la differenza fra il valore medio del prezzo per scontrino fra post e pre
Expand All @@ -655,6 +673,27 @@ var_scontrino
























### RANDOM FOREST

### PERIODO COVID
Expand Down
9 changes: 7 additions & 2 deletions Analisi esplorative/esplorazione_ristorante5.R
Original file line number Diff line number Diff line change
Expand Up @@ -408,10 +408,15 @@ print(

### Stagionalit? considerando tutti gli anni

vendite5_sett_avg <- as.numeric(vendite5_sett_avg)
initial <- rep(NA, 36)
vendite5_sett_avg <- c(initial, vendite5_sett_avg)
vendite5_sett_avg <- ts(vendite5_sett_avg, start = decimal_date(as.Date("2018-01-01")), frequency=52)

print(
ggseasonplot(vendite5_sett_avg, year.labels=TRUE, year.labels.left=TRUE) +
ylab("euro") +
ggtitle("Seasonal plot Ristorante 5: vendite settimanali")
ylab("Vendite") +
ggtitle("Seasonal Plot ristorante 5")
)

# Nel grafico precedente c'? un problema sull'anno 2018, che dovrebbe partire dalla
Expand Down
4 changes: 2 additions & 2 deletions Analisi esplorative/esplorazione_ristorante6.R
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,8 @@ vendite6_sett_avg <- ts(vendite6_sett_avg, start = decimal_date(as.Date("2018-01

print(
ggseasonplot(vendite6_sett_avg, year.labels=TRUE, year.labels.left=TRUE) +
ylab("euro") +
ggtitle("Seasonal plot Ristorante 6: vendite settimanali")
ylab("Vendite") +
ggtitle("Seasonal Plot ristorante 6")
)

# Nel grafico precedente c'? un problema sull'anno 2018, che dovrebbe partire dalla
Expand Down

0 comments on commit 54f1723

Please sign in to comment.