StefZimm / Master-Project

0 stars 0 forks source link

Generation of interactive graphics #4

Closed StefZimm closed 2 years ago

StefZimm commented 2 years ago

Hi @DeliveranceBougie ,

the aggregated tables (https://github.com/StefZimm/Master-Project/tree/main/tables) of numeric and categorical variables must be processed into interactive graphs. We need to define which graphics we want to offer on the platform and what the functions must be capable of in order to show the desired results.

DeliveranceBougie commented 2 years ago

@StefZimm I wonder if it will be too much of a heavy lift to use a map as one of the graphics? Potentially with a bubble plot with a variety of interaction selections, such as age and happiness for each state, by year or change in rating year over year.

Some other ideas I came across. Not that we should use them all, but looking at ideas:

life expectancy at birth population pyramid - age, pop, sex select range of years for interactive plot https://personal.tcu.edu/kylewalker/articles/walker-2016-spatial-demography.html

income and poverty estimates https://www.census.gov/library/visualizations/2021/demo/highlights-2020.html

Several ideas here https://ourworldindata.org/world-population-growth

StefZimm commented 2 years ago

Using maps could be very ambitious. I have never really worked with regional data. But potentially this would be possible with the SOEP. There is even a small practical example on the soep.companion:

http://companion.soep.de/Working%20with%20SOEP%20Data/Working%20with%20spatial%20data%20in%20R.html

But I would think this is even more ambitious than our original plan. And Data access could be a problem. I think if we want the good shape files you have to come to Germany because of data protection (http://companion.soep.de/Data%20Structure%20of%20SOEPcore/Editions.html#onsite-edition). I think only then you can work with this data.

Population pyramids are cool. But that would only affect very few variables. I would rather like our graphs to be usable for any categorical or numerical variable. So I prefer graph types that are always usable. Boxplot, lines and bar chart. But maybe we could have something like a landing page where special graphs like population pyramids could be displayed?

income and poverty estimates could also be done with density or bulletplots. Maybe also something for this landing page.

But I would be super happy if we could manage to offer universally usable lines, bars and maybe boxplots as 3 usable graphs for each variable, using aggregated tables rather than raw data. Every additional graphic would be nice to have for me.

StefZimm commented 2 years ago

functions to create graphics should be stored here:

https://github.com/StefZimm/Master-Project/blob/main/scripts/graph_creation_FUN.R

StefZimm commented 2 years ago

First Draft of usable graphics:

lineplot_percentages

lineplot_mean

grafik

heatmap

DeliveranceBougie commented 2 years ago

Regarding the topic I brought up about allowing the user to select states to highlight on a line graph, what I found may indicate too heavy of a lift, but I will let you decide.

Here is the dashboard I had in mind. I remembered wrong, and it is not shiny. Dashboard GitHub

Here is a plotly way to make the selection,but they created a button for each country (scroll toward the bottom). I am not sure we could do this without aggregating on state or when # of categories are > x. If @joesaks1 is not already familiar with a less complicated way to do this, we can ask @fkeusch01 Monday or just add it to the 'nice to have/next steps' list.

DeliveranceBougie commented 2 years ago

@StefZimm My boxplot code is not sufficient for our purpose. The trouble is the aggregated data. I have been trying to see if I can wrap your code with ggplotly, but I end up with an empty plot. If you have not already tried this, I wonder if you know how to correct it? Example: plot <- ggplotly(data%>% ggplot(aes(factor(year))) + geom_boxplot(data = data, aes(ymin = min, lower = ptile25 , middle = median, upper = ptile90, ymax = ptile99), stat = "identity") + theme(strip.background = element_blank(), axis.title.x=element_blank(), axis.text.x = element_text(angle = 90), axis.title.y=element_blank())+ coord_flip()+ labs(title = title, caption = "Data: SOEP-Core v.36"))

I also flipped the coordinates and wanted to see if you like this layout. The tick marks would need to be rotated if we use this layout. image

StefZimm commented 2 years ago

same color palette for all graphics remains a problem.