Learn R Programming

DisasterAlert (version 1.0.0)

create_sentiment_map: Create Interactive Sentiment Map

Description

This function creates an interactive Leaflet map showing disaster locations colored by sentiment.

Usage

create_sentiment_map(data, lat_col = "Latitude", lon_col = "Longitude")

Value

Leaflet map object

Arguments

data

A data.frame with sentiment analysis results

lat_col

Name of latitude column (default: "Latitude")

lon_col

Name of longitude column (default: "Longitude")

Author

Hossein Hassani and Leila Marvian Mashhad and Nadejda Komendantova.

Examples

Run this code
sample_data <- data.frame(
  City               = c("CityA", "CityB", "CityC"),
  Longitude          = c(10.0, 11.5, 12.2),
  Latitude           = c(50.1, 49.9, 50.5),
  sentiment_score    = c( 2.5, -1.0,  0.0),
  sentiment_category = c("Positive", "Negative", "Neutral"),
  User_Comment       = c(
    "Amazing rescue efforts!",
    "Terrible flooding last night.",
    "All calm here."
  ),
  stringsAsFactors = FALSE
)

sentiment_map <- create_sentiment_map(sample_data,
                                      lat_col = "Latitude",
                                      lon_col = "Longitude")

sentiment_map

Run the code above in your browser using DataLab