The assignment requires to create a web page using R Markdown that features a map created with Leaflet. Then, host it online.
I will show the code and plot below what I did. Basically, I selected the data longitude and latidude data of the Civil Society Organizations available at the [mapaosc.ipea.gov.br] and base in the city of Araruama. Then I plot then in leaflet.
#loading the required libraries and reading the file
library(leaflet)
## Warning: pacote 'leaflet' foi compilado no R versão 4.4.1
library (dplyr)
## Warning: pacote 'dplyr' foi compilado no R versão 4.4.1
##
## Anexando pacote: 'dplyr'
## Os seguintes objetos são mascarados por 'package:stats':
##
## filter, lag
## Os seguintes objetos são mascarados por 'package:base':
##
## intersect, setdiff, setequal, union
library(tidyr)
## Warning: pacote 'tidyr' foi compilado no R versão 4.4.1
dados <- read.csv("C:/Users/r1705296/OneDrive/IPEA/licenca capacitacao 2024/Data Science Specialization/files/ongs_araruama.csv", sep = ";",
stringsAsFactors = FALSE)
Now, cheking the data
head(dados[, 1:4])
head(dados$geo_localizacao)
dim(dados)
Now I will separate, convert and adjust the original long and lat data
dados3 <- dados %>%
mutate(geo_localizacao = gsub("POINT \\(|\\)", "", geo_localizacao)) %>%
separate(geo_localizacao, into = c("long", "lat"), sep = " ", convert = TRUE)
Inserting the creating the data in leaflet and ploting it
mapa_osc <- leaflet(data = dados3) %>%
addTiles() %>%
addMarkers(~long, ~lat, popup = ~id_osc) %>%
addControl("<h3 style='color: black;'>Civil Society Organizations in Araruama-RJ-Brazil</h3>", position = "topright", className = "map-title")
mapa_osc