#reads the different functions in all the libraries
library(ggplot2)
library(sf)
## Linking to GEOS 3.11.0, GDAL 3.5.3, PROJ 9.1.0; sf_use_s2() is TRUE
library(plotly)
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
#reads shape file
br_mun<-read_sf('counties 3')
#making cuts into smaller parts and adding labeles to the legend
br_mun$TAAMERIND<-cut(br_mun$TAAMERIND,breaks = c(0,200,400,600,800,1000,2000,3000,4000,5000,6000,7000),
labels=c('0-200','200-400','400-600','600-800','800-1000','1000-2000','2000-3000','3000-4000','4000-5000','5000-6000','6000-7000'))
Oregon_map<-
  #map creation
ggplot()+
  geom_sf(aes(fill=TAAMERIND),data=br_mun)+
  #labeling the lengend
  scale_fill_viridis_d(name='Population')+
  #creates title, subititle and alt text.
  labs(title = "Native American density in the state of Oregon",
       subtitle = "Oregon ",
       alt = "This is a chloropleth map of the population of Native Americans in the state of Oregon.")
# maeks map interactive.
  ggplotly(Oregon_map,tooltip = "all")