diff --git a/.Rhistory b/.Rhistory index 74b0558..65be83f 100644 --- a/.Rhistory +++ b/.Rhistory @@ -1,512 +1,512 @@ -colnames(df3) -print(df3) -year_country_gdp <- df3 %>% select( TIME_PERIOD, geo, OBS_VALUE) -year_country_gdp <- na.omit(year_country_gdp) -colnames(year_country_gdp) -df3 %>% group_by(geo) %>% str() -str(year_country_gdp) -# Plot -ggplot(year_country_gdp, aes(x = TIME_PERIOD, y = OBS_VALUE, color = geo, label = geo)) + -geom_line() + +tabPanel("Table", dataTableOutput('table')) +), +width = 9 +), +fluid = TRUE +) +) +# Backend +server <- function(input, output, session) { +output$table <- renderDataTable({ +merged_df[, !names(merged_df) %in% c("OBS_VALUE.x", "OBS_VALUE.y", "geometry")] +}, options = list(pageLength = 10)) +# Plot module +output$final_plot <- renderPlotly({ +final_plot <- ggplot(filter(merged_df, geo %in% input$countries), +aes(x = TIME_PERIOD, y = house_prices_wo_hicp, color = geo, +text = paste("Kraj: ", geo, "
", "Rok: ", TIME_PERIOD, "
", +"Cena nieruchomości: ", house_prices_wo_hicp))) + +geom_line(aes(group = geo), linetype = "dotted", size = 1) + geom_point() + -geom_text(aes(label = geo), hjust = -0.1, size = 3)+ -labs(x = "Rok", y = 'PKB per capita w PPP [PPS_EU27_2020=100]') + -scale_x_continuous(breaks=seq(2010,2024,2)) -year_country_gdp -# ################################################## -# House price index HPI -df1 -house_price_index <- df1 %>% select( TIME_PERIOD, geo, OBS_VALUE) -house_price_index <- na.omit(house_price_index) -colnames(house_price_index) -df1 %>% group_by(geo) %>% str() -str(house_price_index) -# Plot -ggplot(house_price_index, aes(x = TIME_PERIOD, y = OBS_VALUE, color = geo, label = geo)) + -geom_line() + +geom_text(data = filter(merged_df, geo %in% input$countries) %>% group_by(geo) %>% slice(n()), +aes(label = "", hjust = -0.2, size = 4)) + +stat_function(fun = function(x) 100*(1+input$range[1]/100)^(x-2015), aes(colour = paste0(as.character(input$range[1]), "% Compounding")), inherit.aes = FALSE) + +stat_function(fun = function(x) 100*(1+input$range[2]/100)^(x-2015), aes(colour = paste0(as.character(input$range[2]), "% Compounding")), inherit.aes = FALSE) + +scale_x_continuous(breaks = seq(2010, 2024, 2)) + +labs(x = "Rok", y = "Indeks cen nieruchomości zdyskontowany o wartość inflacji [2015 = 100]", +color = "Countries") + +theme(axis.title = element_blank()) +plotly_plot <- ggplotly(final_plot, tooltip = "text") +for (i in 1:length(plotly_plot$x$data)) { +if (plotly_plot$x$data[[i]]$name == paste0(as.character(input$range[1]), "% Compounding") || plotly_plot$x$data[[i]]$name == paste0(as.character(input$range[1]), "% Compounding")) { +plotly_plot$x$data[[i]]$hoverinfo <- "name+y" +} +} +plotly_plot %>% layout(showlegend = TRUE, legend = list(title = list(text = "Countries"))) +}) +# Map module +output$mymap <- renderLeaflet({ +leaflet() %>% +addProviderTiles(providers$CartoDB.Positron) %>% +addPolygons(data=mapdata_new, +fillOpacity = 0.6, # Przezroczystość +stroke = TRUE, # Borders visible +color = "grey", # Border color +weight = 1, +fillColor = ~qpal(mapdata_new$substr_house_prices_wo_hicp), +popup = popup_content, +popupOptions = popupOptions(maxWidth ="100%", closeOnClick = TRUE) +) %>% +setView( lat = 49, lng = 14, zoom = 4) %>% +addLegend("bottomright", colors = qpal_colors, +title = " Real house prices \n index (2022) ", +labels = qpal_labs, +opacity = 1) +}) # End of map module +}# End of server +# Run +shinyApp(ui, server) +print(unique(map_df$geo)) +print(unique(map_df$region)) +library(shiny) +library(leaflet) +library(ggplot2) +library(dplyr) +print(unique(map_df$geo)) +print(unique(map_df$region)) +# print(length(map_df$geo)) +# Frontend +ui <- fluidPage( +sidebarLayout( +sidebarPanel( +# Compound interest +sliderInput("range", "Compound interest:",min = 0, max = 10, value = c(4,8)),textOutput("Compound interest slider"), +# Checkboxes +checkboxGroupInput("countries", "Chosen countries:", +choiceNames = map_df$region, +choiceValues = map_df$geo, +selected = c("PL", "DE", "CZ"), +inline = TRUE, +width = "75%" +), +width=3 +), +mainPanel( +h1("Real house prices index"), +tabsetPanel( +tabPanel("Plot", plotlyOutput("final_plot")), +tabPanel("Map", leafletOutput("mymap")), +tabPanel("Table", dataTableOutput('table')) +), +width = 9 +), +fluid = TRUE +) +) +# Backend +server <- function(input, output, session) { +output$table <- renderDataTable({ +merged_df[, !names(merged_df) %in% c("OBS_VALUE.x", "OBS_VALUE.y", "geometry")] +}, options = list(pageLength = 10)) +# Plot module +output$final_plot <- renderPlotly({ +final_plot <- ggplot(filter(merged_df, geo %in% input$countries), +aes(x = TIME_PERIOD, y = house_prices_wo_hicp, color = geo, +text = paste("Kraj: ", geo, "
", "Rok: ", TIME_PERIOD, "
", +"Cena nieruchomości: ", house_prices_wo_hicp))) + +geom_line(aes(group = geo), linetype = "dotted", size = 1) + geom_point() + -geom_text(data = house_price_index %>% -group_by(geo) %>% -slice(n() - 1), -aes(label = geo, hjust = -1, size = 4))+ -scale_x_continuous(breaks=seq(2010,2024,2)) -labs(x = "Rok", y = 'Indeks Cen nieruchomości [cena z 2015 roku = 100]') -house_price_index -# HICP - Harmonised Index for Consumer Prices -df -hicp_index <- df %>% select( TIME_PERIOD, geo, OBS_VALUE) -hicp_index <- na.omit(hicp_index) -colnames(hicp_index) -df %>% group_by(geo) %>% str() -str(hicp_index) -# Plot -ggplot(hicp_index, aes(x = TIME_PERIOD, y = OBS_VALUE, color = geo, label = geo)) + -geom_line() + +geom_text(data = filter(merged_df, geo %in% input$countries) %>% group_by(geo) %>% slice(n()), +aes(label = "", hjust = -0.2, size = 4)) + +stat_function(fun = function(x) 100*(1+input$range[1]/100)^(x-2015), aes(colour = paste0(as.character(input$range[1]), "% Compounding")), inherit.aes = FALSE) + +stat_function(fun = function(x) 100*(1+input$range[2]/100)^(x-2015), aes(colour = paste0(as.character(input$range[2]), "% Compounding")), inherit.aes = FALSE) + +scale_x_continuous(breaks = seq(2010, 2024, 2)) + +labs(x = "Rok", y = "Indeks cen nieruchomości zdyskontowany o wartość inflacji [2015 = 100]", +color = "Countries") + +theme(axis.title = element_blank()) +plotly_plot <- ggplotly(final_plot, tooltip = "text") +for (i in 1:length(plotly_plot$x$data)) { +if (plotly_plot$x$data[[i]]$name == paste0(as.character(input$range[1]), "% Compounding") || plotly_plot$x$data[[i]]$name == paste0(as.character(input$range[1]), "% Compounding")) { +plotly_plot$x$data[[i]]$hoverinfo <- "name+y" +} +} +plotly_plot %>% layout(showlegend = TRUE, legend = list(title = list(text = "Countries"))) +}) +# Map module +output$mymap <- renderLeaflet({ +leaflet() %>% +addProviderTiles(providers$CartoDB.Positron) %>% +addPolygons(data=mapdata_new, +fillOpacity = 0.6, # Przezroczystość +stroke = TRUE, # Borders visible +color = "grey", # Border color +weight = 1, +fillColor = ~qpal(mapdata_new$substr_house_prices_wo_hicp), +popup = popup_content, +popupOptions = popupOptions(maxWidth ="100%", closeOnClick = TRUE) +) %>% +setView( lat = 49, lng = 14, zoom = 4) %>% +addLegend("bottomright", colors = qpal_colors, +title = " Real house prices \n index (2022) ", +labels = qpal_labs, +opacity = 1) +}) # End of map module +}# End of server +# Run +shinyApp(ui, server) +library(shiny) +library(leaflet) +library(ggplot2) +library(dplyr) +print(unique(map_df$geo)) +print(unique(map_df$region)) +# print(length(map_df$geo)) +# Frontend +ui <- fluidPage( +sidebarLayout( +sidebarPanel( +# Compound interest +sliderInput("range", "Compound interest:",min = 0, max = 10, value = c(4,8)),textOutput("Compound interest slider"), +# Checkboxes +checkboxGroupInput("countries", "Chosen countries:", +choiceNames = map_df$region, +choiceValues = map_df$geo, +selected = c("PL", "DE", "CZ"), +inline = TRUE, +width = "75%" +) +width=3 +library(shiny) +library(leaflet) +library(ggplot2) +library(dplyr) +print(unique(map_df$geo)) +print(unique(map_df$region)) +# print(length(map_df$geo)) +# Frontend +ui <- fluidPage( +sidebarLayout( +sidebarPanel( +# Compound interest +sliderInput("range", "Compound interest:",min = 0, max = 10, value = c(4,8)),textOutput("Compound interest slider"), +# Checkboxes +checkboxGroupInput("countries", "Chosen countries:", +choiceNames = map_df$region, +choiceValues = map_df$geo, +selected = c("PL", "DE", "CZ"), +inline = TRUE, +width = "75%" +), +width=3 +), +mainPanel( +h1("Real house prices index"), +tabsetPanel( +tabPanel("Plot", plotlyOutput("final_plot")), +tabPanel("Map", leafletOutput("mymap")), +tabPanel("Table", dataTableOutput('table')) +), +width = 9 +), +fluid = TRUE +) +) +# Backend +server <- function(input, output, session) { +output$table <- renderDataTable({ +merged_df[, !names(merged_df) %in% c("OBS_VALUE.x", "OBS_VALUE.y", "geometry")] +}, options = list(pageLength = 10)) +# Plot module +output$final_plot <- renderPlotly({ +final_plot <- ggplot(filter(merged_df, geo %in% input$countries), +aes(x = TIME_PERIOD, y = house_prices_wo_hicp, color = geo, +text = paste("Kraj: ", geo, "
", "Rok: ", TIME_PERIOD, "
", +"Cena nieruchomości: ", house_prices_wo_hicp))) + +geom_line(aes(group = geo), linetype = "dotted", size = 1) + geom_point() + -geom_text(data = hicp_index %>% -group_by(geo) %>% -slice(n()), -aes(label = geo, hjust = -0.2, size = 4)) + -labs(x = "Rok", y = 'Indeks inflacji konsumenckiej HICP [2015 = 100]') + -scale_x_continuous(breaks=seq(2010,2024,2)) -hicp_index -# Merge the two data frames using the 'country' and 'date' columns -merged_df <- merge(house_price_index, hicp_index, by = c("geo", "TIME_PERIOD")) -merged_df -# Create a new column that divides 'value1' by 'value2' -merged_df$house_prices_wo_hicp <- merged_df$OBS_VALUE.x - merged_df$OBS_VALUE.y -merged_df$TIME_PERIOD -merged_df$compound_growth <- 1 * (1 + 0.02) ^ (1:(merged_df$TIME_PERIOD-2015)) -# View the resulting merged data frame with the divided values -merged_df -merged_df <- na.omit(merged_df) -colnames(merged_df) -merged_df %>% group_by(geo) %>% str() -str(merged_df) -merged_df <- merged_df %>% filter(!geo %in% c("TR")) -# Plot -ggplot(merged_df, aes(x = TIME_PERIOD, y = house_prices_wo_hicp, color = geo)) + -geom_line(linetype="dotted", size=1) + -geom_point(aes(x=TIME_PERIOD, y=house_prices_wo_hicp)) + -geom_text(data = merged_df %>% -group_by(geo) %>% -slice(n()), -aes(label = geo, hjust = -0.2, size = 4)) + -#stat_function(fun=function(x) 100*(1.04)^(x-2015), aes(colour = "4% Compounding")) + -#stat_function(fun=function(x) 100*(1.07)^(x-2015), aes(colour = "7% Compounding")) + -scale_x_continuous(breaks=seq(2010,2024,2)) + -labs(x = "Year", y = 'Indeks cen nieruchomości zdyskontowany o wartość inflacji [2015 = 100]') -map_df <- merged_df %>% select( geo, house_prices_wo_hicp, TIME_PERIOD) -map_df <- filter(map_df, TIME_PERIOD == 2022) -map_df -merged_df -# Plot -ggplot(hicp_index, aes(x = TIME_PERIOD, y = OBS_VALUE, color = geo, label = geo)) + -geom_line() + +geom_text(data = filter(merged_df, geo %in% input$countries) %>% group_by(geo) %>% slice(n()), +aes(label = "", hjust = -0.2, size = 4)) + +stat_function(fun = function(x) 100*(1+input$range[1]/100)^(x-2015), aes(colour = paste0(as.character(input$range[1]), "% Compounding")), inherit.aes = FALSE) + +stat_function(fun = function(x) 100*(1+input$range[2]/100)^(x-2015), aes(colour = paste0(as.character(input$range[2]), "% Compounding")), inherit.aes = FALSE) + +scale_x_continuous(breaks = seq(2010, 2024, 2)) + +labs(x = "Rok", y = "Indeks cen nieruchomości zdyskontowany o wartość inflacji [2015 = 100]", +color = "Countries") + +theme(axis.title = element_blank()) +plotly_plot <- ggplotly(final_plot, tooltip = "text") +for (i in 1:length(plotly_plot$x$data)) { +if (plotly_plot$x$data[[i]]$name == paste0(as.character(input$range[1]), "% Compounding") || plotly_plot$x$data[[i]]$name == paste0(as.character(input$range[1]), "% Compounding")) { +plotly_plot$x$data[[i]]$hoverinfo <- "name+y" +} +} +plotly_plot %>% layout(showlegend = TRUE, legend = list(title = list(text = "Countries"))) +}) +# Map module +output$mymap <- renderLeaflet({ +leaflet() %>% +addProviderTiles(providers$CartoDB.Positron) %>% +addPolygons(data=mapdata_new, +fillOpacity = 0.6, # Przezroczystość +stroke = TRUE, # Borders visible +color = "grey", # Border color +weight = 1, +fillColor = ~qpal(mapdata_new$substr_house_prices_wo_hicp), +popup = popup_content, +popupOptions = popupOptions(maxWidth ="100%", closeOnClick = TRUE) +) %>% +setView( lat = 49, lng = 14, zoom = 4) %>% +addLegend("bottomright", colors = qpal_colors, +title = " Real house prices \n index (2022) ", +labels = qpal_labs, +opacity = 1) +}) # End of map module +}# End of server +# Run +shinyApp(ui, server) +library(shiny) +library(leaflet) +library(ggplot2) +library(dplyr) +print(unique(map_df$geo)) +print(unique(map_df$region)) +# print(length(map_df$geo)) +# Frontend +ui <- fluidPage( +sidebarLayout( +sidebarPanel( +# Compound interest +sliderInput("range", "Compound interest:",min = 0, max = 10, value = c(4,8)),textOutput("Compound interest slider"), +# Checkboxes +tags$head(tags$style(HTML(".checkbox {margin-left:15px}"))), +checkboxGroupInput("countries", "Chosen countries:", +choiceNames = map_df$region, +choiceValues = map_df$geo, +selected = c("PL", "DE", "CZ"), +inline = TRUE, +width = "75%" +), +width=3 +), +mainPanel( +h1("Real house prices index"), +tabsetPanel( +tabPanel("Plot", plotlyOutput("final_plot")), +tabPanel("Map", leafletOutput("mymap")), +tabPanel("Table", dataTableOutput('table')) +), +width = 9 +), +fluid = TRUE +) +) +# Backend +server <- function(input, output, session) { +output$table <- renderDataTable({ +merged_df[, !names(merged_df) %in% c("OBS_VALUE.x", "OBS_VALUE.y", "geometry")] +}, options = list(pageLength = 10)) +# Plot module +output$final_plot <- renderPlotly({ +final_plot <- ggplot(filter(merged_df, geo %in% input$countries), +aes(x = TIME_PERIOD, y = house_prices_wo_hicp, color = geo, +text = paste("Kraj: ", geo, "
", "Rok: ", TIME_PERIOD, "
", +"Cena nieruchomości: ", house_prices_wo_hicp))) + +geom_line(aes(group = geo), linetype = "dotted", size = 1) + geom_point() + -geom_text(data = hicp_index %>% -group_by(geo) %>% -slice(n()), -aes(label = geo, hjust = -0.2, size = 4)) + -labs(x = "Rok", y = 'Indeks inflacji konsumenckiej HICP [2015 = 100]') + -scale_x_continuous(breaks=seq(2010,2024,2)) -write.csv(merged_df, ".//merged_df.csv") -hicp_index -write.csv(hicp_index, ".//hicp_index.csv") -df = read.csv(".//data//compound_interest_housing") +geom_text(data = filter(merged_df, geo %in% input$countries) %>% group_by(geo) %>% slice(n()), +aes(label = "", hjust = -0.2, size = 4)) + +stat_function(fun = function(x) 100*(1+input$range[1]/100)^(x-2015), aes(colour = paste0(as.character(input$range[1]), "% Compounding")), inherit.aes = FALSE) + +stat_function(fun = function(x) 100*(1+input$range[2]/100)^(x-2015), aes(colour = paste0(as.character(input$range[2]), "% Compounding")), inherit.aes = FALSE) + +scale_x_continuous(breaks = seq(2010, 2024, 2)) + +labs(x = "Rok", y = "Indeks cen nieruchomości zdyskontowany o wartość inflacji [2015 = 100]", +color = "Countries") + +theme(axis.title = element_blank()) +plotly_plot <- ggplotly(final_plot, tooltip = "text") +for (i in 1:length(plotly_plot$x$data)) { +if (plotly_plot$x$data[[i]]$name == paste0(as.character(input$range[1]), "% Compounding") || plotly_plot$x$data[[i]]$name == paste0(as.character(input$range[1]), "% Compounding")) { +plotly_plot$x$data[[i]]$hoverinfo <- "name+y" +} +} +plotly_plot %>% layout(showlegend = TRUE, legend = list(title = list(text = "Countries"))) +}) +# Map module +output$mymap <- renderLeaflet({ +leaflet() %>% +addProviderTiles(providers$CartoDB.Positron) %>% +addPolygons(data=mapdata_new, +fillOpacity = 0.6, # Przezroczystość +stroke = TRUE, # Borders visible +color = "grey", # Border color +weight = 1, +fillColor = ~qpal(mapdata_new$substr_house_prices_wo_hicp), +popup = popup_content, +popupOptions = popupOptions(maxWidth ="100%", closeOnClick = TRUE) +) %>% +setView( lat = 49, lng = 14, zoom = 4) %>% +addLegend("bottomright", colors = qpal_colors, +title = " Real house prices \n index (2022) ", +labels = qpal_labs, +opacity = 1) +}) # End of map module +}# End of server +# Run +shinyApp(ui, server) +library(shiny) +library(leaflet) +library(ggplot2) library(dplyr) -# install.packages("ggplot2") +print(unique(map_df$geo)) +print(unique(map_df$region)) +# print(length(map_df$geo)) +# Frontend +ui <- fluidPage( +sidebarLayout( +sidebarPanel( +# Compound interest +sliderInput("range", "Compound interest:",min = 0, max = 10, value = c(4,8)),textOutput("Compound interest slider"), +# Checkboxes +# tags$head(tags$style(HTML(".checkbox {margin-left:15px}"))), +checkboxGroupInput("countries", "Chosen countries:", +choiceNames = map_df$region, +choiceValues = map_df$geo, +selected = c("PL", "DE", "CZ"), +inline = TRUE, +width = "75%" +), +width=3 +), +mainPanel( +h1("Real house prices index"), +tabsetPanel( +tabPanel("Plot", plotlyOutput("final_plot")), +tabPanel("Map", leafletOutput("mymap")), +tabPanel("Table", dataTableOutput('table')) +), +width = 9 +), +fluid = TRUE +) +) +# Backend +server <- function(input, output, session) { +output$table <- renderDataTable({ +merged_df[, !names(merged_df) %in% c("OBS_VALUE.x", "OBS_VALUE.y", "geometry")] +}, options = list(pageLength = 10)) +# Plot module +output$final_plot <- renderPlotly({ +final_plot <- ggplot(filter(merged_df, geo %in% input$countries), +aes(x = TIME_PERIOD, y = house_prices_wo_hicp, color = geo, +text = paste("Kraj: ", geo, "
", "Rok: ", TIME_PERIOD, "
", +"Cena nieruchomości: ", house_prices_wo_hicp))) + +geom_line(aes(group = geo), linetype = "dotted", size = 1) + +geom_point() + +geom_text(data = filter(merged_df, geo %in% input$countries) %>% group_by(geo) %>% slice(n()), +aes(label = "", hjust = -0.2, size = 4)) + +stat_function(fun = function(x) 100*(1+input$range[1]/100)^(x-2015), aes(colour = paste0(as.character(input$range[1]), "% Compounding")), inherit.aes = FALSE) + +stat_function(fun = function(x) 100*(1+input$range[2]/100)^(x-2015), aes(colour = paste0(as.character(input$range[2]), "% Compounding")), inherit.aes = FALSE) + +scale_x_continuous(breaks = seq(2010, 2024, 2)) + +labs(x = "Rok", y = "Indeks cen nieruchomości zdyskontowany o wartość inflacji [2015 = 100]", +color = "Countries") + +theme(axis.title = element_blank()) +plotly_plot <- ggplotly(final_plot, tooltip = "text") +for (i in 1:length(plotly_plot$x$data)) { +if (plotly_plot$x$data[[i]]$name == paste0(as.character(input$range[1]), "% Compounding") || plotly_plot$x$data[[i]]$name == paste0(as.character(input$range[1]), "% Compounding")) { +plotly_plot$x$data[[i]]$hoverinfo <- "name+y" +} +} +plotly_plot %>% layout(showlegend = TRUE, legend = list(title = list(text = "Countries"))) +}) +# Map module +output$mymap <- renderLeaflet({ +leaflet() %>% +addProviderTiles(providers$CartoDB.Positron) %>% +addPolygons(data=mapdata_new, +fillOpacity = 0.6, # Przezroczystość +stroke = TRUE, # Borders visible +color = "grey", # Border color +weight = 1, +fillColor = ~qpal(mapdata_new$substr_house_prices_wo_hicp), +popup = popup_content, +popupOptions = popupOptions(maxWidth ="100%", closeOnClick = TRUE) +) %>% +setView( lat = 49, lng = 14, zoom = 4) %>% +addLegend("bottomright", colors = qpal_colors, +title = " Real house prices \n index (2022) ", +labels = qpal_labs, +opacity = 1) +}) # End of map module +}# End of server +# Run +shinyApp(ui, server) +library(shiny) +library(leaflet) library(ggplot2) -df = read.csv(".//data//compound_interest_housing") -df[,c("geo", "TIME_PERIOD", "OBS_VALUE")] library(dplyr) -# install.packages("ggplot2") -library(ggplot2) -map_df = read.csv(".//data//compound_interest_housing") -map_df = read.csv(".//data//compound_interest_housing.csv") -map_df -map_df = read.csv(".//data//compound_interest_housing_2.csv") -map_df -map_df = read.csv(".//data//compound_interest_housing_3.csv") -map_df -map_df = read.csv(".//data//compound_interest_housing.csv") -map_df -map_df = read.csv(".//data//compound_interest_housing.csv") -map_df -ggplot(map_df, aes(x = TIME_PERIOD, y = compound_interest, color = geo)) + -geom_line(linetype="dotted", size=1) + -geom_point(aes(x=TIME_PERIOD, y=compound_interest)) + -geom_text(data = map_df %>% -group_by(geo) %>% -slice(n()), -aes(label = geo, hjust = -0.2, size = 4)) + -stat_function(fun=function(x) 100*(1.04)^(x-2015), aes(colour = "4% Compounding")) + -stat_function(fun=function(x) 100*(1.07)^(x-2015), aes(colour = "7% Compounding")) + -scale_x_continuous(breaks=seq(2010,2024,2)) + -labs(x = "Year", y = 'Indeks cen nieruchomości zdyskontowany o wartość inflacji [2015 = 100]') -ggplot(map_df, aes(x = TIME_PERIOD, y = compound_interest, color = geo)) + -geom_line(linetype="dotted", size=1) + -geom_point(aes(x=TIME_PERIOD, y=compound_interest)) + -geom_text(data = map_df %>% -group_by(geo) %>% -slice(n()), -aes(label = geo, hjust = -0.2, size = 4)) + -scale_x_continuous(breaks=seq(2010,2024,2)) + -labs(x = "Year", y = 'Indeks cen nieruchomości zdyskontowany o wartość inflacji [2015 = 100]') -ggplot(map_df, aes(x = TIME_PERIOD, y = compound_interest, color = geo)) + -geom_line(linetype="dotted", size=1) + -geom_point(aes(x=TIME_PERIOD, y=compound_interest)) + -geom_text(data = map_df %>% -group_by(geo) %>% -slice(n()), -aes(label = geo, hjust = -0.2, size = 4)) + -scale_x_continuous(breaks=seq(2010,2024,2)) + -labs(x = "Year", y = 'wartość mieszkania jako % składany powyżej inflacji') -ggplot(map_df, aes(x = TIME_PERIOD, y = compound_interest, color = geo)) + -geom_point(aes(x=TIME_PERIOD, y=compound_interest)) + -geom_text(data = map_df %>% -group_by(geo) %>% -slice(n()), -aes(label = geo, hjust = -0.2, size = 4)) + -scale_x_continuous(breaks=seq(2010,2024,2)) + -labs(x = "Year", y = 'wartość mieszkania jako % składany powyżej inflacji') -plot(map_df$compound_interest) -plot(map_df$geo,map_df$compound_interest) -barplot(map_df$geo, map_df$compound_interest) -ggplot(map_df, aes(x = TIME_PERIOD, y = compound_interest, color = geo)) + -geom_point(aes(x=TIME_PERIOD, y=compound_interest)) + -geom_text(data = map_df %>% -group_by(geo) %>% -slice(n()), -aes(label = geo, hjust = -0.2, size = 4)) + -scale_x_continuous(breaks=seq(2010,2024,2)) + -labs(x = "Year", y = 'wartość mieszkania jako % składany powyżej inflacji') -# install.packages("tidyverse") -library(ggplot2) -install.packages("tidyverse") -install.packages("tidyverse") -library(tidyverse) -library(tidyverse) -install.packages("tidyverse") -install.packages("tidyverse") -library(tidyverse) -install.packages("tidyverse") -install.packages("tidyverse") -library(tidyverse) -# install.packages("tidyverse") -library(ggplot2) -view(mapdata) -map_df = read.csv(".//data//compound_interest_housing.csv") -map_df -ggplot(map_df, aes(x = TIME_PERIOD, y = compound_interest, color = geo)) + -geom_point(aes(x=TIME_PERIOD, y=compound_interest)) + -geom_text(data = map_df %>% -group_by(geo) %>% -slice(n()), -aes(label = geo, hjust = -0.2, size = 4)) + -scale_x_continuous(breaks=seq(2010,2024,2)) + -labs(x = "Year", y = 'wartość mieszkania jako % składany powyżej inflacji') -view(mapdata) -mapdata <- map_data("world") -library(tidyverse) -# install.packages("tidyverse") -library(ggplot2) -map_df = read.csv(".//data//compound_interest_housing.csv") -map_df -ggplot(map_df, aes(x = TIME_PERIOD, y = compound_interest, color = geo)) + -geom_point(aes(x=TIME_PERIOD, y=compound_interest)) + -geom_text(data = map_df %>% -group_by(geo) %>% -slice(n()), -aes(label = geo, hjust = -0.2, size = 4)) + -scale_x_continuous(breaks=seq(2010,2024,2)) + -labs(x = "Year", y = 'wartość mieszkania jako % składany powyżej inflacji') -mapdata <- map_data("world") -ggplot(map_df, aes(x = TIME_PERIOD, y = compound_interest, color = geo)) + -geom_point(aes(x=TIME_PERIOD, y=compound_interest)) + -geom_text(data = map_df %>% -group_by(geo), -aes(label = geo, hjust = -0.2, size = 4)) + -scale_x_continuous(breaks=seq(2010,2024,2)) + -labs(x = "Year", y = 'wartość mieszkania jako % składany powyżej inflacji') -library(dplyr) -# install.packages("tidyverse") -library(ggplot2) -map_df = read.csv(".//data//compound_interest_housing.csv") -map_df -ggplot(map_df, aes(x = TIME_PERIOD, y = compound_interest, color = geo)) + -geom_point(aes(x=TIME_PERIOD, y=compound_interest)) + -geom_text(data = map_df %>% -group_by(geo) %>% -slice(n()), -aes(label = geo, hjust = -0.2, size = 4)) + -scale_x_continuous(breaks=seq(2010,2024,2)) + -labs(x = "Year", y = 'wartość mieszkania jako % składany powyżej inflacji') -mapdata <- map_data("world") -view(mapdata) -mapdata <- left_join(mapdata, map_df, by="region") -test <- test %>% filter("Czech republic" ) -test -test <- mapdata %>% filter("Czech republic" ) -test -test <- mapdata %>% filter("Afghanistan" ) -test -test <- filter(mapdata, region="Afghanistan" ) -test -test <- filter(mapdata, region="Aruba" ) -test -filter(mapdata, region="Aruba" ) -filter(mapdata, region="Aruba" ) -filter(mapdata, region=="Aruba" ) -filter(mapdata, region=="Czech republic" ) -filter(mapdata, region=="Czech Republic" ) -filter(mapdata, region=="Hungary -" ) -write.csv(mapdata, "./mapdata.csv") -map_df = read.csv(".//data//compound_interest_housing.csv") -map_df -ggplot(map_df, aes(x = TIME_PERIOD, y = compound_interest, color = geo)) + -geom_point(aes(x=TIME_PERIOD, y=compound_interest)) + -geom_text(data = map_df %>% -group_by(geo) %>% -slice(n()), -aes(label = geo, hjust = -0.2, size = 4)) + -scale_x_continuous(breaks=seq(2010,2024,2)) + -labs(x = "Year", y = 'wartość mieszkania jako % składany powyżej inflacji') -mapdata <- map_data("world") -mapdata <- left_join(mapdata, map_df, by="region") -mapdata <- left_join(mapdata, map_df, by="region", relation = "many-to-many") -view(mapdata) -mapdata <- mapdata %>% filter(!is.na(mapdata$compound_interest)) -view(mapdata) -map1 <- ggplot(mapdata, aes(x = long, y = lat, group = group)) + -geom_polygon(aes(fill = compound_interest), color = "black") -map1 -map1 <- ggplot(mapdata, aes(x = long, y = lat, group = group)) + -geom_polygon(aes(fill = compound_interest), color = "black") + -scale_fill_gradient(name="compound interest", low="yellow", high = "red", na.value = "grey50") -map1 <- ggplot(mapdata, aes(x = long, y = lat, group = group)) + -geom_polygon(aes(fill = compound_interest), color = "black") + -scale_fill_gradient(name="compound interest", low="yellow", high = "red", na.value = "grey50") -view(mapdata) -map1 -map1 <- ggplot(mapdata, aes(x = long, y = lat, group = group)) + -geom_polygon(aes(fill = compound_interest), color = "black") + -scale_fill_gradient(name="compound interest", low="blue", high = "yellow", na.value = "grey50") -map1 -map1 <- ggplot(mapdata, aes(x = long, y = lat, group = group)) + -geom_polygon(aes(fill = compound_interest), color = "black") + -scale_fill_gradient(name="compound interest", low="blue", high = "red", na.value = "grey50") -map1 -map1 <- ggplot(mapdata, aes(x = long, y = lat, group = group)) + -geom_polygon(aes(fill = compound_interest), color = "black") + -scale_fill_gradient(name="compound interest", palette(colorRamps::matlab.like), na.value = "grey50") -map1 -library(colorRamps) -install.packages("colorRamps") -library(colorRamps) -map_df = read.csv(".//data//compound_interest_housing.csv") -map_df -ggplot(map_df, aes(x = TIME_PERIOD, y = compound_interest, color = geo)) + -geom_point(aes(x=TIME_PERIOD, y=compound_interest)) + -geom_text(data = map_df %>% -group_by(geo) %>% -slice(n()), -aes(label = geo, hjust = -0.2, size = 4)) + -scale_x_continuous(breaks=seq(2010,2024,2)) + -labs(x = "Year", y = 'wartość mieszkania jako % składany powyżej inflacji') -# filter data to have both coordinates and value -mapdata <- map_data("world") -mapdata <- left_join(mapdata, map_df, by="region", relation = "many-to-many") -# filter data to have both coordinates and value -mapdata <- map_data("world") -mapdata <- left_join(mapdata, map_df, by="region", relation = "many-to-many") -mapdata <- mapdata %>% filter(!is.na(mapdata$compound_interest)) -map1 <- ggplot(mapdata, aes(x = long, y = lat, group = group)) + -geom_polygon(aes(fill = compound_interest), color = "black") + -scale_fill_gradient(name="compound interest", palette(colorRamps::matlab.like), na.value = "grey50") -map1 -view(mapdata) -library(dplyr) -library(tidyverse) -# install.packages("colorRamps") -library(ggplot2) -library(colorRamps) -map_df = read.csv(".//data//compound_interest_housing.csv") -map_df -ggplot(map_df, aes(x = TIME_PERIOD, y = compound_interest, color = geo)) + -geom_point(aes(x=TIME_PERIOD, y=compound_interest)) + -geom_text(data = map_df %>% -group_by(geo) %>% -slice(n()), -aes(label = geo, hjust = -0.2, size = 4)) + -scale_x_continuous(breaks=seq(2010,2024,2)) + -labs(x = "Year", y = 'wartość mieszkania jako % składany powyżej inflacji') -# filter data to have both coordinates and value -mapdata <- map_data("world") -mapdata <- left_join(mapdata, map_df, by="region", relation = "many-to-many") -mapdata <- left_join(mapdata, map_df, by="region") -, relation = "many-to-many" -mapdata <- left_join(mapdata, map_df, by="region", relation = "many-to-many") -map1 -library(dplyr) -library(tidyverse) -# install.packages("colorRamps") -library(ggplot2) -library(colorRamps) -map_df = read.csv(".//data//compound_interest_housing.csv") -map_df -ggplot(map_df, aes(x = TIME_PERIOD, y = compound_interest, color = geo)) + -geom_point(aes(x=TIME_PERIOD, y=compound_interest)) + -geom_text(data = map_df %>% -group_by(geo) %>% -slice(n()), -aes(label = geo, hjust = -0.2, size = 4)) + -scale_x_continuous(breaks=seq(2010,2024,2)) + -labs(x = "Year", y = 'wartość mieszkania jako % składany powyżej inflacji') -# filter data to have both coordinates and value -mapdata <- map_data("world") -mapdata <- left_join(mapdata, map_df, by="region", relation = "many-to-many") -mapdata <- left_join(mapdata, map_df, by="region") -map1 <- ggplot(mapdata, aes(x = long, y = lat, group = group)) + -geom_polygon(aes(fill = compound_interest), color = "black") + -scale_fill_gradient(name="compound interest", palette(colorRamps::matlab.like), na.value = "grey50") -map1 -mapdata <- left_join(mapdata, map_df, by="region") -mapdata -mapdata <- mapdata %>% filter(!is.na(mapdata$compound_interest)) -View(mapdata) -mapdata <- mapdata %>% filter(!is.na(mapdata$compound_interest.x)) -map1 <- ggplot(mapdata, aes(x = long, y = lat, group = group)) + -geom_polygon(aes(fill = compound_interest), color = "black") + -scale_fill_gradient(name="compound interest", palette(colorRamps::matlab.like), na.value = "grey50") -map1 <- ggplot(mapdata, aes(x = long, y = lat, group = group)) + -geom_polygon(aes(fill = compound_interest.x), color = "black") + -scale_fill_gradient(name="compound interest", palette(colorRamps::matlab.like), na.value = "grey50") -map1 <- ggplot(mapdata, aes(x = long, y = lat, group = group)) + -geom_polygon(aes(fill = compound_interest.x), color = "black") -map1 -map1 <- ggplot(mapdata, aes(x = long, y = lat, group = group)) + -geom_polygon(aes(fill = compound_interest.x), color = "black") + -scale_fill_gradient(name="compound interest", palette = matlab.like, na.value = "grey50") -map1 -map1 <- ggplot(mapdata, aes(x = long, y = lat, group = group)) + -geom_polygon(aes(fill = compound_interest.x), color = "black") + -scale_fill_gradient(name="compound interest", palette = "matlab.like", na.value = "grey50") -map1 -map1 <- ggplot(mapdata, aes(x = long, y = lat, group = group)) + -geom_polygon(aes(fill = compound_interest.x), color = "black") + -scale_fill_gradient(name="compound interest", low = "yellow", high = "red", na.value = "grey50") -map1 -map1 <- ggplot(mapdata, aes(x = long, y = lat, group = group)) + -geom_polygon(aes(fill = compound_interest.x), color = "black") + -scale_fill_gradient(name="compound interest", low = "white", high = "black", na.value = "grey50") -map1 -# filter data to have both coordinates and value -geo_list <- c("Belarus", "Greece", "United Kingdom") -mapdata <- map_data("world") -mapdata <- left_join(mapdata, map_df, by="region") -mapdata <- mapdata %>% filter(!is.na(mapdata$compound_interest.x)| mapdata$region %in% geo_list) -# filter data to have both coordinates and value -geo_list <- c("Belarus", "Greece", "United Kingdom") -mapdata <- map_data("world") -mapdata <- left_join(mapdata, map_df, by="region") -mapdata <- mapdata %>% filter(!is.na(mapdata$compound_interest.x)| mapdata$region %in% geo_list) -mapdata <- map_data("world") -mapdata1 <- left_join(mapdata, map_df, by="region") -mapdata2 <- mapdata1 %>% filter(!is.na(mapdata1$compound_interest.x)| mapdata1$region %in% geo_list) -mapdata1 -mapdata2 <- mapdata1 %>% filter(!is.na(mapdata1$compound_interest)| mapdata1$region %in% geo_list) -mapdata <- map_data("world") -mapdata1 <- left_join(mapdata, map_df, by="region") -mapdata2 <- mapdata1 %>% filter(!is.na(mapdata1$compound_interest)| mapdata1$region %in% geo_list) -map1 <- ggplot(mapdata, aes(x = long, y = lat, group = group)) + -geom_polygon(aes(fill = compound_interest), color = "black") + -scale_fill_gradient(name="compound interest", low = "white", high = "black", na.value = "grey50") -map1 -mapdata2 -mapdata2 -mapdata2 -View(mapdata2) -mapdata2 <- mapdata1 %>% filter(mapdata1$region %in% geo_list) -#!is.na(mapdata1$compound_interest)| -mapdata2 -View(mapdata2) -mapdata2 <- mapdata1 %>% filter(!is.na(mapdata1$compound_interest)| mapdata1$region %in% geo_list) -mapdata2 -map1 <- ggplot(mapdata, aes(x = long, y = lat, group = group)) + -geom_polygon(aes(fill = compound_interest), color = "black") + -scale_fill_gradient(name="compound interest", low = "white", high = "black", na.value = "grey50") -map1 -map1 <- ggplot(mapdata2, aes(x = long, y = lat, group = group)) + -geom_polygon(aes(fill = compound_interest), color = "black") + -scale_fill_gradient(name="compound interest", low = "white", high = "black", na.value = "grey50") -map1 -view(mapdata) -map1 <- ggplot(mapdata2, aes(x = long, y = lat, group = group)) + -geom_polygon(aes(fill = compound_interest), color = "black") + -scale_fill_gradient(name="compound interest", low = "white", high = "black", na.value = "yellow") -map1 -# filter data to have both coordinates and value -geo_list <- c("Belarus", "Greece", "England") -mapdata <- map_data("world") -mapdata1 <- left_join(mapdata, map_df, by="region") -mapdata2 <- mapdata1 %>% filter(!is.na(mapdata1$compound_interest)| mapdata1$region %in% geo_list) -mapdata2 -map1 <- ggplot(mapdata2, aes(x = long, y = lat, group = group)) + -geom_polygon(aes(fill = compound_interest), color = "black") + -scale_fill_gradient(name="compound interest", low = "white", high = "black", na.value = "yellow") -map1 -# filter data to have both coordinates and value -geo_list <- c("Belarus", "Greece", "Latvia", "Albania", -"Switzerland", "Bosnia and Herzegowina", "Ukraine", "Scotland") -mapdata <- map_data("world") -mapdata1 <- left_join(mapdata, map_df, by="region") -mapdata2 <- mapdata1 %>% filter(!is.na(mapdata1$compound_interest)| mapdata1$region %in% geo_list) -mapdata2 -map1 <- ggplot(mapdata2, aes(x = long, y = lat, group = group)) + -geom_polygon(aes(fill = compound_interest), color = "black") + -scale_fill_gradient(name="compound interest", low = "white", high = "black", na.value = "yellow") -map1 -# filter data to have both coordinates and value -geo_list <- c("Belarus", "Greece", "Latvia", "Albania", -"Switzerland", "Bosnia and Herzegowina", "Ukraine", "Scotland", "Turkey") -mapdata <- map_data("world") -mapdata1 <- left_join(mapdata, map_df, by="region") -mapdata1 <- left_join(mapdata, map_df, by="region", relationship = "many-to-many") -mapdata2 <- mapdata1 %>% filter(!is.na(mapdata1$compound_interest)| mapdata1$region %in% geo_list) -mapdata2 -map1 <- ggplot(mapdata2, aes(x = long, y = lat, group = group)) + -geom_polygon(aes(fill = compound_interest), color = "black") + -scale_fill_gradient(name="compound interest", low = "white", high = "black", na.value = "yellow") -map1 -# filter data to have both coordinates and value -geo_list <- c("Belarus", "Greece", "Latvia", "Albania", -"Switzerland", "Bosnia and Herzegowina", "Ukraine", -"UK", "Turkey", "Serbia", "Macedonia", "North Macedonia") -mapdata <- map_data("world") -mapdata1 <- left_join(mapdata, map_df, by="region", relationship = "many-to-many") -mapdata2 <- mapdata1 %>% filter(!is.na(mapdata1$compound_interest)| mapdata1$region %in% geo_list) -mapdata2 -map1 <- ggplot(mapdata2, aes(x = long, y = lat, group = group)) + -geom_polygon(aes(fill = compound_interest), color = "black") + -scale_fill_gradient(name="compound interest", low = "white", high = "black", na.value = "yellow") -map1 -# filter data to have both coordinates and value -geo_list <- c("Belarus", "Greece", "Latvia", "Albania", -"Switzerland", "Bosnia and Herzegovina", "Ukraine", -"UK", "Turkey", "Serbia", "Kosovo" "Moldova", "North Macedonia", -mapdata <- map_data("world") -mapdata1 <- left_join(mapdata, map_df, by="region", relationship = "many-to-many") -mapdata2 <- mapdata1 %>% filter(!is.na(mapdata1$compound_interest)| mapdata1$region %in% geo_list) -mapdata2 -map1 <- ggplot(mapdata2, aes(x = long, y = lat, group = group)) + -geom_polygon(aes(fill = compound_interest), color = "black") + -scale_fill_gradient(name="compound interest", low = "white", high = "black", na.value = "yellow") -map1 -# filter data to have both coordinates and value -geo_list <- c("Belarus", "Greece", "Latvia", "Albania", -"Switzerland", "Bosnia and Herzegovina", "Ukraine", -"UK", "Turkey", "Serbia", "Kosovo", "Moldova", "North Macedonia", -"Montenegro") -mapdata <- map_data("world") -mapdata1 <- left_join(mapdata, map_df, by="region", relationship = "many-to-many") -mapdata2 <- mapdata1 %>% filter(!is.na(mapdata1$compound_interest)| mapdata1$region %in% geo_list) -mapdata2 -map1 <- ggplot(mapdata2, aes(x = long, y = lat, group = group)) + -geom_polygon(aes(fill = compound_interest), color = "black") + -scale_fill_gradient(name="compound interest", low = "white", high = "black", na.value = "yellow") -map1 -# filter data to have both coordinates and value -geo_list <- c("Belarus", "Greece", "Latvia", "Albania", -"Switzerland", "Bosnia and Herzegovina", "Ukraine", -"UK", "Turkey", "Serbia", "Kosovo", "Moldova", "North Macedonia", -"Montenegro", "cyprus", "Malta") -mapdata <- map_data("world") -mapdata1 <- left_join(mapdata, map_df, by="region", relationship = "many-to-many") -mapdata2 <- mapdata1 %>% filter(!is.na(mapdata1$compound_interest)| mapdata1$region %in% geo_list) -mapdata2 -map1 <- ggplot(mapdata2, aes(x = long, y = lat, group = group)) + -geom_polygon(aes(fill = compound_interest), color = "black") + -scale_fill_gradient(name="compound interest", low = "white", high = "black", na.value = "yellow") -map1 +# Frontend +ui <- fluidPage( +sidebarLayout( +sidebarPanel( +# Compound interest +sliderInput("range", "Compound interest:",min = 0, max = 10, value = c(4,8)),textOutput("Compound interest slider"), +# Checkboxes +# tags$head(tags$style(HTML(".checkbox {margin-left:15px}"))), +checkboxGroupInput("countries", "Chosen countries:", +choiceNames = map_df$region, +choiceValues = map_df$geo, +selected = c("PL", "DE", "CZ"), +inline = TRUE, +width = "75%" +), +width=3 +), +mainPanel( +h1("Real house prices index"), +tabsetPanel( +tabPanel("Plot", plotlyOutput("final_plot")), +tabPanel("Map", leafletOutput("mymap")), +tabPanel("Table", dataTableOutput('table')) +), +width = 9 +), +fluid = TRUE +) +) +# Backend +server <- function(input, output, session) { +output$table <- renderDataTable({ +merged_df[, !names(merged_df) %in% c("OBS_VALUE.x", "OBS_VALUE.y", "geometry")] +}, options = list(pageLength = 10)) +# Plot module +output$final_plot <- renderPlotly({ +final_plot <- ggplot(filter(merged_df, geo %in% input$countries), +aes(x = TIME_PERIOD, y = house_prices_wo_hicp, color = geo, +text = paste("Kraj: ", geo, "
", "Rok: ", TIME_PERIOD, "
", +"Cena nieruchomości: ", house_prices_wo_hicp))) + +geom_line(aes(group = geo), linetype = "dotted", size = 1) + +geom_point() + +geom_text(data = filter(merged_df, geo %in% input$countries) %>% group_by(geo) %>% slice(n()), +aes(label = "", hjust = -0.2, size = 4)) + +stat_function(fun = function(x) 100*(1+input$range[1]/100)^(x-2015), aes(colour = paste0(as.character(input$range[1]), "% Compounding")), inherit.aes = FALSE) + +stat_function(fun = function(x) 100*(1+input$range[2]/100)^(x-2015), aes(colour = paste0(as.character(input$range[2]), "% Compounding")), inherit.aes = FALSE) + +scale_x_continuous(breaks = seq(2010, 2024, 2)) + +labs(x = "Rok", y = "Indeks cen nieruchomości zdyskontowany o wartość inflacji [2015 = 100]", +color = "Countries") + +theme(axis.title = element_blank()) +plotly_plot <- ggplotly(final_plot, tooltip = "text") +for (i in 1:length(plotly_plot$x$data)) { +if (plotly_plot$x$data[[i]]$name == paste0(as.character(input$range[1]), "% Compounding") || plotly_plot$x$data[[i]]$name == paste0(as.character(input$range[1]), "% Compounding")) { +plotly_plot$x$data[[i]]$hoverinfo <- "name+y" +} +} +plotly_plot %>% layout(showlegend = TRUE, legend = list(title = list(text = "Countries"))) +}) +# Map module +output$mymap <- renderLeaflet({ +leaflet() %>% +addProviderTiles(providers$CartoDB.Positron) %>% +addPolygons(data=mapdata_new, +fillOpacity = 0.6, # Przezroczystość +stroke = TRUE, # Borders visible +color = "grey", # Border color +weight = 1, +fillColor = ~qpal(mapdata_new$substr_house_prices_wo_hicp), +popup = popup_content, +popupOptions = popupOptions(maxWidth ="100%", closeOnClick = TRUE) +) %>% +setView( lat = 49, lng = 14, zoom = 4) %>% +addLegend("bottomright", colors = qpal_colors, +title = " Real house prices \n index (2022) ", +labels = qpal_labs, +opacity = 1) +}) # End of map module +}# End of server +# Run +shinyApp(ui, server) diff --git a/.Rproj.user/shared/notebooks/paths b/.Rproj.user/shared/notebooks/paths index 69b8c12..f8ba964 100644 --- a/.Rproj.user/shared/notebooks/paths +++ b/.Rproj.user/shared/notebooks/paths @@ -1,3 +1,6 @@ -C:/Users/Lewy/Desktop/Wizualizacja danych/experiments.R="98FA7FC8" -C:/Users/Lewy/Desktop/Wizualizacja danych/projekt_1_housing.R="B49036B1" -C:/Users/Lewy/Desktop/Wizualizacja danych/projekt_2_housing.R="569F1072" +/home/lewy/Downloads/projekt_1_housing.r="FDB568A6" +/home/lewy/UE_house_prices_wizualizacja/projekt_1_housing.R="305524DE" +/home/lewy/UE_house_prices_wizualizacja/projekt_1_housing_new.r="7F985654" +/home/lewy/UE_house_prices_wizualizacja/test.R="0EE8C830" +/home/lewy/UE_house_prices_wizualizacja/test_checkboxes.R="7F311D9A" +/home/lewy/UE_house_prices_wizualizacja/webapp.R="7174B648" diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5b6a065 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.Rproj.user +.Rhistory +.RData +.Ruserdata diff --git a/test.R b/test.R new file mode 100644 index 0000000..795e400 --- /dev/null +++ b/test.R @@ -0,0 +1,42 @@ +## Only run examples in interactive R sessions +if (interactive()) { + + ui <- fluidPage( + checkboxGroupInput("variable", "Variables to show:", + c("Cylinders" = "cyl", + "Transmission" = "am", + "Gears" = "gear")), + tableOutput("data") + ) + + server <- function(input, output, session) { + output$data <- renderTable({ + mtcars[, c("mpg", input$variable), drop = FALSE] + }, rownames = TRUE) + } + + shinyApp(ui, server) + + ui <- fluidPage( + checkboxGroupInput("icons", "Choose icons:", + choiceNames = + list(icon("calendar"), icon("bed"), + icon("cog"), icon("bug")), + choiceValues = + list("calendar", "bed", "cog", "bug") + ), + textOutput("txt") + ) + + server <- function(input, output, session) { + output$txt <- renderText({ + icons <- paste(input$icons, collapse = ", ") + paste("You chose", icons) + }) + } + + shinyApp(ui, server) +} + + + diff --git a/test_checkboxes.R b/test_checkboxes.R new file mode 100644 index 0000000..c38d2fa --- /dev/null +++ b/test_checkboxes.R @@ -0,0 +1,28 @@ + ## Only run examples in interactive R sessions + if (interactive()) { + + # Frontend + ui <- fluidPage( + # Checkboxes + checkboxGroupInput("countries", "Choose countries:", + choiceNames = unique(merged_df$geo), + choiceValues = unique(merged_df$geo) + ), + + # list of chosen + textOutput("txt") + ) + + # Backend + server <- function(input, output, session) { + + # Printer + output$txt <- renderText({ + chosen_countries <- paste(input$countries, collapse = ", ") + paste("You chose", chosen_countries) + }) + + } + + shinyApp(ui, server) + } \ No newline at end of file diff --git a/webapp.R b/webapp.R index 3168f24..1a44c1d 100644 --- a/webapp.R +++ b/webapp.R @@ -11,12 +11,13 @@ ui <- fluidPage( # Compound interest sliderInput("range", "Compound interest:",min = 0, max = 10, value = c(4,8)),textOutput("Compound interest slider"), + # Checkboxes - # tags$head(tags$style(HTML(".checkbox {margin-left:15px}"))), + #tags$head(tags$style(HTML(".checkbox {margin-left:15px}"))), checkboxGroupInput("countries", "Chosen countries:", - choiceNames = map_df$region, - choiceValues = map_df$geo, - selected = c("PL", "DE", "CZ"), + choiceNames = c(map_df$region), + choiceValues = c(map_df$geo), + selected = c("PL", "CZ", "DE"), inline = TRUE, width = "75%" ), @@ -24,6 +25,7 @@ ui <- fluidPage( + width=3 ),