Watts-College / cpp-529-spr-2022

https://watts-college.github.io/cpp-529-spr-2022/
0 stars 2 forks source link

Final Project: Map missing #25

Closed asukajames closed 2 years ago

asukajames commented 2 years ago

In the Community Demographic tab, the map does not show up as follows:

Screenshot 2022-04-23 132831

I uploaded my dorling file in the Github and used the codes:


# DATA STEPS 

# load dorling cartogram from github
# map already contains census data and groups from clustering 

github.url <- "https://raw.githubusercontent.com/asukajames/DC/main/DC_dorling.geojson"
DC <- geojson_read( x=github.url,  what="sp" )

# reproject the map 
DC2 <- spTransform( DC, CRS("+init=epsg:3395") )

# convert the sp map format to 
# an sf (simple features) format:
# ggmap requires the sf format
DC.sf <- st_as_sf( DC2 )

# separate out the data frame from the map
d <- as.data.frame( DC.sf )

I changed the xmin/max and ymin/max in Out put:


renderPlot({

# split the selected variable into deciles 

get_data <- 
  reactive({
             DC.sf <- 
             DC.sf %>% 
             mutate( q = ntile( get(input$demographics), 10 ) )  
          })

ggplot( get_data() ) +
    geom_sf( aes( fill = q ), color=NA ) +
    coord_sf( datum=NA ) +
    labs( title = paste0( "Choropleth of Select Demographics: ", toupper(input$demographics) ),
          caption = "Source: Harmonized Census Files",
          fill = "Population Deciles" ) +
    scale_fill_gradientn( colours=rev(ocean.balance(10)), guide = "colourbar" ) + 
    xlim( xmin = -8800000, xmax = -8500000 ) + 
    ylim( ymin = 4800000, ymax = 4600000 )

})

Any advice would be greatly appreciated!

asukajames commented 2 years ago

I figured out!