Level-two and below headings…
…are all contained in the same section.
Example text.
You may include any number of plots in a section.
library(plotly)
## Warning: package 'plotly' was built under R version 4.3.3
## Loading required package: ggplot2
##
## 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
library(maps)
library(dplyr)
## Warning: package 'dplyr' was built under R version 4.3.3
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(sf)
## Warning: package 'sf' was built under R version 4.3.3
## Linking to GEOS 3.11.2, GDAL 3.8.2, PROJ 9.3.1; sf_use_s2() is TRUE
library(ggplot2)
# Replace spaces with proper path syntax or use double backslashes
roads_path <- "J:/Shared drives/Policy & Research/Mobile Units/tl_2019_48_prisecroads.shp"
# Read shapefile
roads <- st_read(roads_path)
## Reading layer `tl_2019_48_prisecroads' from data source
## `J:\Shared drives\Policy & Research\Mobile Units\tl_2019_48_prisecroads.shp'
## using driver `ESRI Shapefile'
## Simple feature collection with 14791 features and 4 fields
## Geometry type: LINESTRING
## Dimension: XY
## Bounding box: xmin: -106.6286 ymin: 25.89511 xmax: -93.51942 ymax: 36.50069
## Geodetic CRS: NAD83
# Inspect the data
head(roads)
## Simple feature collection with 6 features and 4 fields
## Geometry type: LINESTRING
## Dimension: XY
## Bounding box: xmin: -98.21048 ymin: 32.20477 xmax: -96.88762 ymax: 32.69156
## Geodetic CRS: NAD83
## LINEARID FULLNAME RTTYP MTFCC geometry
## 1 1102671600066 S Walton Walker Rmp M S1200 LINESTRING (-96.88763 32.69...
## 2 1102671599582 S Walton Walker Rmp M S1200 LINESTRING (-96.88762 32.69...
## 3 110449721117 West S Lp M S1200 LINESTRING (-98.20534 32.20...
## 4 110449719101 W S Lp M S1200 LINESTRING (-98.21048 32.20...
## 5 1106039033336 E S Lp M S1200 LINESTRING (-98.19615 32.21...
## 6 110449719099 E S Lp M S1200 LINESTRING (-98.16929 32.23...
library(plotly)
library(ggplot2)
library(plotly)
library(ggplot2)
# Clean ggplot without background
map_clean <- ggplot() +
geom_sf(data = roads, aes(color = MTFCC), size = 0.5) +
theme_void() +
labs(title = "Primary and Secondary Roads in Texas")
# Convert to interactive Plotly
interactive_map <- ggplotly(map_clean, tooltip = "MTFCC") %>%
layout(
paper_bgcolor = 'rgba(0,0,0,0)', # transparent background
plot_bgcolor = 'rgba(0,0,0,0)', # transparent plot area
xaxis = list(visible = FALSE), # hide x-axis
yaxis = list(visible = FALSE), # hide y-axis
showlegend = TRUE
) %>%
config(displayModeBar = FALSE) # remove toolbar
interactive_map