Shiny choropleth map multiple indicators - r

I have seen many tutorials online, but I am not able so see the answer anywhere. I have a dataset with several indicators. Let's say I have a df with 947 observations (municipalities) with seven indicators (municipality id plus other municipality-level indicators). Some of these indicators are continous (for instance, the percentage of men in a municipality or the average age of people living in a municipality).
I also have a shapefile with the municipality boundaries. The sf file has also 947 observations and the same unique identifier.
I am trying to create a shiny app so that it displays a map for each of these seven indicators (displaying a choropleth map with the quantile distribution). In other words, the user should be able to select which indicator is displayed in the drop-down menu.
Do you know of any tutorial I could use? Any advice?

Related

How to create bar graph from qualitative data in R?

I have two columns for olympic data showing the name of the team and one showing the type of medal won by the team. I am trying to calculate the number of medals won by each team in the olympics and then plot a bar graph from the data.
I do not know how to best go about it. The observations for teams repeat as they were extracted from a bigger data set as they show each participants nationality. I want to calculate for each team. However, there are mutiple teams and thus want to do it for the top 10 teams. I thus would also need assistance in ranking them.
Appreciation in this regard will be appreciated.

Best way to transform source data?

Working in R. But I think this question is universal.
Wall Street Journal visualized a dataset on disease infection rates in the U.S.:
X-axis is year. Y-axis is state.
And shade of red per tile is infection rate intensity for that particular state recorded for that year.
The source dataset being visualized is arranged as follows:
Each row in the dataset corresponds to a single infection rate for a single country in a given year. So, each red tile in the visualization corresponds to a row from the dataset.
But what if the dataset looked like this?:
Now, each row corresponds to a state. And each state/row has multiple infection rates, one for each year recorded. This might match how data is captured in the real world because for each year or day (in the case of coronavirus) you track the infection rate, you can just add a new column (rather than a 50 new rows).
The problem is while this layout is more human-friendly, it's not very R-friendly. We can easily create the tile visualization based on the source dataset arrangement where data is arranged by infection rate, but not so easily if it's arranged by state.
So, finally, my question is — is there an easy way to transform data from the second layout to the first, in Excel?
You can use the transpose function in the free, open-source OpenRefine tool to prepare your data file prior to loading it into R.

Multi-functional Shiny App Using Maps and Graphs

I am trying to develop a Shiny App in R for a project that I am working on in order to more efficiently share data and display results of this data for a large working group. I have a spreadsheet with 75 trailheads (points) that contain information related to latitude, longitude, and visitor usage data based on month and year starting in 2016. What I am hoping to do is develop an app that allows users to select all or multiple trailheads and either display the count numbers based on a selected month of a year or a year and have those results be displayed on a map as points based on density as well as a graphical plot that will display the results of the trailheads on a bar graph or something similar that users can look at the geographical dispersion of usage as well as usage trends.
I am have gone through many examples but cannot seem to find any that would allow all this functionality. If anyone can point me in the right direction, as far as locating code, that would be greatly appreciated.

choropleth map time-series map allowing zoom

I have been using both R and QGIS to study GIS, with the intention of publishing choropleth maps to the web. Both pieces of software allow a zoom function on static maps. But, for animated time-series, the only option appears to be to join a series of time snapshots into a movie file.
I would like the user to be able to zoom in during a time series animation.
I'm animating onto a map of New Zealand, and my time-series is events by suburb. While I can aggregate suburb into territorial local authority area to have larger polygons, this removes the suburb detail. Suburb is likely to remain of interest to users.
Will I have to create a series of animations, one for each general geographical area that people might be interested in (e.g. Auckland, Wellington, Christchurch)? That will provide a "selected zoom" option for users. It also means I have to create a set of static maps per predicted geographical location of user interest.
I can't find any solutions for combining zoom and time series with choropleth maps, at least with R and QGIS.
Does anyone have an example of this type of web implementation, preferably showing the options used (QGIS) or the code (R)?

Pie charts in Qgis

I have this problem:
I would like to create a pie chart from a column of a attribute table, and I would like to see this pie chart above the map. The column contains names not nubers...
I work with marine species distribution data and I built a database of records of many many species...
In the specific, I have a column, called 'species', where there are many records (names) of some marine species. Several species may have many records, other species may have only a few numbers of records, so my objective is to graphically see the distribuition of records among the species.
If build a pie chart is a very time consuming procedure, I'd be happy to create a new column of the attribute table with the numbers of different species per year (see the attachments) or to try a totally new approach with R.
Thankyou for your help
img1 http://postimg.org/image/rn56c8l4z/
img2 http://postimg.org/image/e6918ynmj/
You'll most probably get many answers that pie charts are evil because they distort perception.
But along with better alternatives, namely stacked bar charts, you find code examples here
and, as always,
? pie
helps.
You may need to summarize your factor first, e.g. by table.

Resources