0

I am trying to make a point map that replaces the points with pie charts to make the information quicker to understand for the layman.

the alternative is:

"text": statistic "text": statistic "text": statistic "text": statistic

library(shiny)
library(shinydashboard)
library(tidyverse)
library(shinyWidgets)
library(plotly)
library(leaflet)
library(scales)
library(sp)
library(sf)
library(ggplot2)
library(leaflet.minicharts)

ui <- dashboardPage( skin = "purple",
                     dashboardHeader(title = "Practice Map", titleWidth = 400),
                     dashboardSidebar(disable = TRUE),
                     dashboardBody(
                       fluidPage(
                         useShinydashboard(),
                           fluidRow(
                             leafletOutput(outputId = "map")
                           )
  
                         )))

server <- function(input, output) {
  output$map <- renderLeaflet ({
 #extracting coordinates and adding to data
      map.tb <- map%>%
        st_coordinates() %>% 
        as_tibble() %>% 
        rename(lon = 1, lat = 2) %>% 
        bind_cols(map %>% st_drop_geometry())

      l <- leaflet(map) %>% 
        addTiles() %>% 
        addMinicharts(
          lng = map.tb$lon,
          lat = map.tb$lat,
          type = pie,
          chartdata = map.tb[,c(column1,column2,
                                column3,column4)],
          width = 60 * sqrt(map$colmun1) / sqrt(max(map$column1)), transitionTime = 0,
          fillColor = d3.schemeCategory10[1],
          colorPalette = d3.schemeCategory10

I keep getting this error.

Error in match.arg: 'arg' must be NULL or a character vector

does this mean I am missing an argument somewhere?

Let me know if any info is missing.

PotterFan
  • 81
  • 2
  • 7

1 Answers1

0

Not really the way you are trying, but did you consider getting this done via QGIS? you can plot nodes on any map rather easily, and then instead of each point marker plot a pie chart with specified attributes.

you would just need to create a .txt file or similar with the following categories:

NODEx NODEy stat1 stat2 stat3 stat4

of course you can also enrich the file with node names or other infos, but this would work. Finally: -Import the so-created file as delimited text, -Right click the layer -> Poperties -> Diagram

customize the pie chart the way you want. I know I went a bit off track, but sometimes there are better tools for facing the same goal :)