-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.R
121 lines (97 loc) · 3.83 KB
/
app.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
library(shiny)
library(tidyverse)
library(geomtextpath)
ui <- fluidPage(
titlePanel("Gaskostenbremse für Gasverbrauch 2023"),
sidebarLayout(
sidebarPanel(
sliderInput("consumption_2022",
"Verbrauch 2022 (80% davon werden für Pauschale berücksichtigt):",
min = 0,
max = 20000,
value = 10000
),
sliderInput("price_rebate",
"Referenzpreis für Gaspauschale (in Cent pro kWh, Vorschlag Kommission: 12)",
min = 0,
max = 60,
value = 12),
textOutput("max_rebate"),
sliderInput("price_gas_2022",
"Alter Arbeitspreis 2022 (in Cent pro kWh)",
min = 0,
max = 60,
value = 7
),
sliderInput("price_gas_2023",
"Neuer Arbeitspreis 2023 (in Cent pro kWh)",
min = 0,
max = 60,
value = 20
)
),
mainPanel(
plotOutput("plot_costs"),
plotOutput("plot_prices")
)
)
)
server <- function(input, output) {
rebate <-
reactive({input$consumption_2022*max(input$price_gas_2023-input$price_rebate,0) * 0.8/100})
output$max_rebate <- renderText({paste(" \n Maximale Pauschale:",round(rebate()), "€\n ")})
consumption <- 0:20000
cost_norebate <- reactive(consumption*input$price_gas_2023/100)
cost_rebate <- reactive(pmax(0,cost_norebate()-rebate()))
cost_price2022 <- reactive(consumption*input$price_gas_2022/100)
cost_avg_rebate <- reactive(cost_rebate()/consumption*100)
cost_marginal_2023_rebate <- reactive(100*c(0,diff(cost_rebate())))
output$plot_costs <-
renderPlot({
ggplot(mapping = aes(x= consumption))+
geom_textline(mapping = aes(y = cost_norebate()),
color = "blue",
label = "Kosten 2023 zu neuem Preis",
hjust = 0.8
)+
geom_textline(mapping = aes(y = cost_rebate()),
label= paste("Kosten 2023 zu neuem Preis abzgl. maximal einer Pauschale von",
round(rebate(),0),
"€"
),
hjust = 0.8
)+
geom_textline(mapping = aes(y = cost_price2022()),
label= "fiktive Kosten 2023 zu altem Preis",
color = "red",
hjust = 0.8
)+
labs(x = "Verbrauch 2023 (in kWh)",
y = "Gesamtkosten (in €)"
)+
theme_minimal()
})
output$plot_prices <-
renderPlot({
ggplot(mapping = aes(x= consumption))+
geom_textline(mapping = aes(y = cost_avg_rebate()),
label = "durchschnittl. Kosten 2023",
hjust = 0.8
)+
geom_textline(mapping = aes(y = cost_marginal_2023_rebate()),
color = "blue",
label = "marginale Kosten zu Preis in 2023 mit Pauschale",
hjust = 0.8
)+
geom_texthline(yintercept = input$price_gas_2022,
color = "red",
label = "marginale Kosten zu Preis in 2022 ohne Pauschale",
hjust = 0.8
)+
labs(x = "Verbrauch 2023 (in kWh)",
y = "marginale/durchschnittl. Gaskosten (in Cent pro kWh)") +
theme_minimal()
})
}
# Run the application
shinyApp(ui = ui, server = server)