| Title: | Linked Plot Maps for Multivariate High-Resolution Spatio-Temporal Data |
| Version: | 0.1.0 |
| Description: | Create interactive, linked plot maps for multivariate high-resolution spatio-temporal data, such as vehicle trajectories. You can explore the spatial, temporal, and multivariate aspects of the data simultaneously. |
| License: | MIT + file LICENSE |
| Encoding: | UTF-8 |
| RoxygenNote: | 7.3.3 |
| Imports: | leaflet, plotly (≥ 4.10.4), crosstalk, dplyr, ggplot2 (≥ 3.5.2), htmltools, rlang (≥ 1.1.6), viridisLite |
| Depends: | R (≥ 4.1) |
| LazyData: | true |
| URL: | https://hardtme.github.io/DrivePlotR/, https://github.com/hardtme/DrivePlotR |
| Suggests: | testthat (≥ 3.0.0), sf |
| Config/testthat/edition: | 3 |
| BugReports: | https://github.com/hardtme/DrivePlotR/issues |
| NeedsCompilation: | no |
| Packaged: | 2026-06-03 14:43:59 UTC; MarieHardt |
| Author: | Marie Hardt |
| Maintainer: | Marie Hardt <hardtme@iastate.edu> |
| Repository: | CRAN |
| Date/Publication: | 2026-06-08 19:50:10 UTC |
Establish the default behavior for colorpalette Helper function for internal use only.
Description
Establish the default behavior for colorpalette Helper function for internal use only.
Usage
check_colorpalette(shareddata, colorvar = NULL, colorpalette = NULL)
Arguments
shareddata |
The SharedData object provided to the calling function. |
colorvar |
The |
colorpalette |
The |
Value
The color palette to be used for the visualization.
Check the colorvar argument for driveplot_companion()
and driveplot_map()
Helper function for internal use only.
Description
Check the colorvar argument for driveplot_companion()
and driveplot_map()
Helper function for internal use only.
Usage
check_colorvar(shareddata, colorvar)
Arguments
shareddata |
The SharedData object provided to the calling function. |
colorvar |
The |
Value
A value indicating whether colorvar is not a column in the data (NULL), colorvar is a numeric column in the data (TRUE), or colorvar is not a numeric column in the data (FALSE).
Check the latitude and longitude for driveplot_map()
Helper function for internal use only.
Description
Check the latitude and longitude for driveplot_map()
Helper function for internal use only.
Usage
check_lnglat(shareddata, lng, lat)
Arguments
shareddata |
The SharedData object provided to the calling function. |
lng |
The |
lat |
The |
Value
If lng and lat are correctly provided, return NULL. If an sf
geometry column is provided, return a dataframe of the points derived from
the geometry column.
Check the x and y arguments for driveplot_companion()
Helper function for internal use only.
Description
Check the x and y arguments for driveplot_companion()
Helper function for internal use only.
Usage
check_xy(shareddata, arg, argname)
Arguments
shareddata |
The SharedData object provided to the calling function. |
arg |
The |
argname |
The name (x or y) of the argument to be checked. |
Value
The result of the argument tidily evaluated in the environment
of the original data from shareddata.
Check the ylabels argument for driveplot_companions()
Helper function for internal use only.
Description
Check the ylabels argument for driveplot_companions()
Helper function for internal use only.
Usage
check_ylabels(ylabels, ylength)
Arguments
ylabels |
A vector or list of labels provided to the calling function. |
ylength |
The length of the ys argument from the calling function. |
Value
Either ylabels or a list of NULL of length ylength.
Convert a data frame to a SharedData object and warn the user this was done
Description
Helper function for internal use only.
Usage
convert_to_SharedData(df)
Arguments
df |
The provided data object to be converted to a SharedData object. |
Value
A SharedData object.
Blackbox-Driving Data for one drive
Description
This dataset contains drive 7 from the dataset nds_data.
Usage
drive7
Format
A tibble with 321 rows and 34 columns
- drive
integer, identifier for a drive; a drive is defined as the time between starting the car and turning it off again.
- time_utc
POSIXct time stamp for each observation in UTC
- time_cst
POSIXct time stamp for each observation in Central time
GPS-based measurements for each observation:
- gps_elevation
numeric, elevation above sea-level (in m)
- gps_heading
numeric, continuity-corrected direction of the car (in degrees with north at 0 degrees and increasing clockwise) as measured by GPS. The continuity correction takes the initial GPS heading and adds the cumulative sum of the changes in GPS heading for the subsequent observations.
- gps_fix
numeric, value specifying the adequacy of the GPS fix, where 0 = no fix, 1 = time only, 2 = 2D fix, 3 = 3D fix. A gps_fix of 3 is needed for good GPS data.
- gps_sats
integer, the number of satellites covering a position.
- gps_pdop
numeric, position dilution of precision, an overall GPS data quality measure (lower is better)
- gps_hdop
numeric, horizontal dilution of precision, a GPS quality measure for latitude/longitude data (lower is better)
- gps_vdop
numeric, vertical dilution of precision, a GPS quality measure for elevation data (lower is better)
- speed_mph
numeric, speed of the vehicle (in miles per hour)
- speed_source
character, the source of the reported speed, either "gps" or "obd"
- distance_miles
numeric, distance traveled during a drive (in miles)
Measurements by the on-board gyroscope:
- accel_x
numeric, measure of vehicle acceleration along the front-back (longitudinal) axis (in g)
- accel_y
numeric, measure of vehicle acceleration along the right-left (lateral) axis (in g)
- accel_z
numeric, measure of acceleration of the vehicle in the up-down plane (normal/yaw axis) (in g)
- accel_event
numeric, sequential (over time) variable marking when consecutive acceleration values (absolute value of accel_x/y) exceed a threshold of 0.35g for a minimum of 1 second
- accel_event_cat
character, severity categorization of acceleration event into low (0.35-0.44g), medium (0.45-0.59g), and high (>0.6g)
- gyro_x
numeric, angular rotation rate about the right-to-left axis (in degrees/sec)
- gyro_y
numeric, angular rotation rate about the forward-to-backward axis (in degrees/sec)
- gyro_z
numeric, angular rotation rate about the up-to-down axis (in degrees/sec)
- gyro_heading
numeric, calculated heading utilizing compass data and gyro data (in degrees with north at 0 degrees and increasing clockwise). Note that we use non-standard congruence classes for continuity of consecutive values. Due to errors in the raw gyro heading, we use the initial GPS heading value as the initial heading value and then subtract the cumulative sum of gyro_z for the subsequent observations to calculate gyro_heading.
- grav_x
numeric, lateral gravity (in g)
- grav_y
numeric, longitudinal gravity (in g)
- grav_z
numeric, gravity (up-down) (in g)
- roll
numeric, angle about the forward-to-backward axis. 0 = level, positive = tilted to the left (in degrees)
- pitch
numeric, angle about the left-to-right axis where 0 = level, positive = tilted downward (i.e., vehicle going downhill) (in degrees)
- engine_rpm
numeric, current engine revolutions per minute value
- engine_throttle
numeric, engine throttle as a percentage (0-100%)
- cumulative_drive_dist_mi
numeric, the cumulative distance driven in miles at each observation
- gps_minute
factor, the minute component of the timestamp for each observation (00 to 59)
Raw heading measurements:
- gps_heading_raw
numeric, raw GPS heading without continuity correction (in degrees)
- gyro_heading_raw
numeric, raw gyro heading without continuity correction (in degrees)
GPS coordinates in a simple features column:
- geometry
list-column, simple features geometry column with geometry type POINT and CRS WGS84
Create a vehicle trajectory plot map
Description
Create a vehicle trajectory plot map
Usage
driveplot(
shareddata,
lng = NULL,
lat = NULL,
x,
ys,
colorvar = NULL,
maplabel = NA,
colorpalette = NULL,
fillopacity = 1,
xlabel = NULL,
ylabels = NULL,
showlegend = TRUE,
legendtitle = NULL,
plottitle = NULL,
spacing = 0.05,
width = "100%",
height = "100vh"
)
Arguments
shareddata |
A SharedData object containing observations to be plotted. |
lng |
The bare (unquoted) column of shareddata containing longitude (only required if shareddata does not have a geometry column). |
lat |
The bare (unquoted) column of shareddata containing latitude (only required if shareddata does not have a geometry column) |
x |
The bare (unquoted) column from shareddata to be plotted on the horizontal axis. |
ys |
A vector or list of bare (unquoted) columns from shareddata to be plotted on the vertical axes of the companion graphs. |
colorvar |
The bare (unquoted) column in shareddata to which color should be mapped. |
maplabel |
An optional label for the map points. |
colorpalette |
The color palette for the plot; either a single
color (e.g., "red") or one of the viridis color palettes compatible
with leaflet. Run |
fillopacity |
The opacity of the fill of the map points (0 to 1). |
xlabel |
The label for the variable on the horizontal axis. |
ylabels |
A vector or list of labels for the vertical axes of the companion graphs. If provided, it should be the same length as ys. |
showlegend |
Show the plot legend (TRUE) or not (FALSE). |
legendtitle |
The title for the plot legend. |
plottitle |
The title for the plot map. |
spacing |
A value between 0 and 1 for the space between the companion graphs. |
width |
The width of the plot map, provided as a string with one of the following units: %, vh, vw, or px (e.g., "100%" or "400px") |
height |
The height of the plot map, provided as a string with one of the following units: %, vh, vw, or px (e.g., "100%" or "400px") |
Value
A linked plot map.
Examples
## Only run examples in interactive R sessions
if (interactive()) {
library(crosstalk)
data(drive7)
shared_drive <- SharedData$new(drive7)
driveplot(
shareddata = shared_drive,
x = time_cst,
ys = c(speed_mph, gyro_heading, gps_heading),
colorvar = gyro_heading,
maplabel = time_cst,
colorpalette = "viridis",
fillopacity = 1,
xlabel = "Time",
ylabels = c(
"Speed (mph)", "Gyro Heading (degrees)",
"GPS Heading (degrees)"
),
showlegend = TRUE,
legendtitle = "Gyro Heading",
plottitle = "A drive with points colored by gyro heading",
height = "500px"
)
}
Make a single plotly scatter plot from shared drive data
Description
Make a single plotly scatter plot from shared drive data
Usage
driveplot_companion(
shareddata,
x,
y,
colorvar = NULL,
colorpalette = NULL,
xlabel = NULL,
ylabel = NULL,
showlegend = TRUE,
legendtitle = NULL
)
Arguments
shareddata |
A SharedData object containing observations to be plotted. |
x |
The bare (unquoted) column from shareddata to be plotted on the horizontal axis. |
y |
The bare (unquoted) column from shareddata to be plotted on the vertical axis. |
colorvar |
The bare (unquoted) column in shareddata to which color should be mapped. |
colorpalette |
The color palette for the plot; either a single
color (e.g., "red") or one of the viridis color palettes compatible
with leaflet. Run |
xlabel |
The label for the variable on the horizontal axis. |
ylabel |
The label for the variable on the vertical axis. |
showlegend |
Show the plot legend (TRUE) or not (FALSE). |
legendtitle |
The title for the plot legend. |
Value
A plotly scatterplot.
Examples
library(crosstalk)
data(drive7)
shared_drive <- SharedData$new(drive7)
# Time series of speed
driveplot_companion(
shareddata = shared_drive,
x = time_cst,
y = speed_mph
)
# Color points by direction of car
driveplot_companion(
shareddata = shared_drive,
x = time_cst,
y = speed_mph,
colorvar = gyro_heading,
colorpalette = "viridis",
xlabel = "Time",
ylabel = "Speed (MPH)",
showlegend = TRUE,
legendtitle = "Gyro Heading"
)
Make a stack of companion graphs from shared drive data
Description
Make a stack of companion graphs from shared drive data
Usage
driveplot_companions(
shareddata,
x,
ys,
colorvar = NULL,
xlabel = NULL,
ylabels = NULL,
colorpalette = NULL,
showlegend = TRUE,
legendtitle = NULL,
spacing = 0.05,
plotheight = "100vh"
)
Arguments
shareddata |
A SharedData object containing observations to be plotted. |
x |
The bare (unquoted) column from shareddata to be plotted on the horizontal axis. |
ys |
A vector or list of bare (unquoted) columns from shareddata to be plotted on the vertical axes of the companion graphs. |
colorvar |
The bare (unquoted) column in shareddata to which color should be mapped. |
xlabel |
The label for the variable on the horizontal axis. |
ylabels |
A vector or list of labels for the vertical axes of the companion graphs. If provided, it should be the same length as ys. |
colorpalette |
The color palette for the plot; either a single
color (e.g., "red") or one of the viridis color palettes compatible
with leaflet. Run |
showlegend |
Show the plot legend (TRUE) or not (FALSE). |
legendtitle |
The title for the plot legend. |
spacing |
A value between 0 and 1 for the space between the companion graphs. |
plotheight |
The height of the stack of companion graphs, e.g., "100vh" or "400px". |
Value
A stack of plotly scatterplots.
Examples
library(crosstalk)
data(drive7)
shared_drive <- SharedData$new(drive7)
# Linked time series of speed, headings (in GPS and gyro), and GPS quality
driveplot_companions(
shareddata = shared_drive,
x = time_cst,
ys = c(speed_mph, gyro_heading, gps_heading),
colorvar = gps_pdop,
xlabel = "Time",
ylabels = c(
"Speed (mph)", "Gyro Heading (degrees)",
"GPS Heading (degrees)"
),
colorpalette = "viridis",
legendtitle = "GPS PDOP"
)
Create a standalone map
Description
Create a standalone map
Usage
driveplot_map(
shareddata,
lng = NULL,
lat = NULL,
colorvar = NULL,
label = NA,
colorpalette = NULL,
fillopacity = 1,
mapheight = "100vh"
)
Arguments
shareddata |
A SharedData object containing observations to be plotted. |
lng |
The bare (unquoted) column of shareddata containing longitude (only required if shareddata does not have a geometry column). |
lat |
The bare (unquoted) column of shareddata containing latitude (only required if shareddata does not have a geometry column). |
colorvar |
The bare (unquoted) column in shareddata to which color should be mapped. |
label |
An optional label for the map points. |
colorpalette |
The color palette for the plot; either a single
color (e.g., "red") or one of the viridis color palettes compatible
with leaflet. Run |
fillopacity |
The opacity of the fill of the map points (0 to 1). |
mapheight |
The height of the map, e.g, "100vh" or 400px". |
Value
A leaflet map.
Examples
library(crosstalk)
data(drive7)
shared_drive <- SharedData$new(drive7)
# Basic map of one drive
driveplot_map(shareddata = shared_drive)
# Color drive points by direction of car
driveplot_map(
shareddata = shared_drive,
colorvar = gyro_heading,
label = gyro_heading,
colorpalette = "viridis"
)
Create the color palette to be used in driveplot_map()
Description
Helper function for internal use only
Usage
driveplot_map_color(colorvarnumeric, colorpalette, quocolor, ogdata)
Arguments
colorvarnumeric |
An indication of whether the color variable is numeric (TRUE), not numeric (FALSE), or not provided (NULL) |
colorpalette |
The color palette to use; either a single color (e.g., "red") or one of "viridis", "inferno", "magma", or "plasma". |
quocolor |
A quosure containing the color variable. |
ogdata |
The data used to create the domain for the color palette. |
Value
The leaflet color palette to be used in driveplot_map().
Guess latitude and longitude column names
Helper function for internal use only.
Adapted from the leaflet function guessLatLongCols. Rather than looking for
the exact variable names lat or latitude, the regular expression allows for
variables that start or end with lat/latitude for latitude; similarly for
longitude.
Description
Guess latitude and longitude column names
Helper function for internal use only.
Adapted from the leaflet function guessLatLongCols. Rather than looking for
the exact variable names lat or latitude, the regular expression allows for
variables that start or end with lat/latitude for latitude; similarly for
longitude.
Usage
guess_lat_long_cols(names, stopOnFailure = TRUE)
Arguments
names |
Vector of column names. |
stopOnFailure |
Should the function throw an error when it cannot identify latitude and longitude columns in the data (TRUE) or not (FALSE)? |
Value
List with latitude and longitude column names.
Vector of viridis color palettes supported by Leaflet
Description
Helper function
Usage
leaflet_color_palettes()
Details
In a DrivePlotR plot map, the map uses the same color palette as the companion graphs.
Value
Vector of viridis color palettes supported by Leaflet.
Examples
leaflet_color_palettes()
Blackbox-Driving Data for a number of drives
Description
This dataset contains 28 drives ranging in length from just over 2 hours to just 45 secs.
Usage
nds_data
Format
A tibble with 23187 rows and 35 columns
- drive
integer, identifier for a drive; a drive is defined as the time between starting the car and turning it off again.
- time_utc
POSIXct time stamp for each observation in UTC
- time_cst
POSIXct time stamp for each observation in Central time
GPS-based measurements for each observation:
- gps_long
numeric, geographic longitude in degrees with CRS WGS84
- gps_lat
numeric, geographic latitude in degrees with CRS WGS84
- gps_elevation
numeric, elevation above sea-level (in m)
- gps_heading
numeric, continuity-corrected direction of the car (in degrees with north at 0 degrees and increasing clockwise) as measured by GPS. The continuity correction takes the initial GPS heading and adds the cumulative sum of the changes in GPS heading for the subsequent observations.
- gps_fix
numeric, value specifying the adequacy of the GPS fix, where 0 = no fix, 1 = time only, 2 = 2D fix, 3 = 3D fix. A gps_fix of 3 is needed for good GPS data.
- gps_sats
integer, the number of satellites covering a position.
- gps_pdop
numeric, position dilution of precision, an overall GPS data quality measure (lower is better)
- gps_hdop
numeric, horizontal dilution of precision, a GPS quality measure for latitude/longitude data (lower is better)
- gps_vdop
numeric, vertical dilution of precision, a GPS quality measure for elevation data (lower is better)
- speed_mph
numeric, speed of the vehicle (in miles per hour)
- speed_source
character, the source of the reported speed, either "gps" or "obd"
- distance_miles
numeric, distance traveled during a drive (in miles)
Measurements by the on-board gyroscope:
- accel_x
numeric, measure of vehicle acceleration along the front-back (longitudinal) axis (in g)
- accel_y
numeric, measure of vehicle acceleration along the right-left (lateral) axis (in g)
- accel_z
numeric, measure of acceleration of the vehicle in the up-down plane (normal/yaw axis) (in g)
- accel_event
numeric, sequential (over time) variable marking when consecutive acceleration values (absolute value of accel_x/y) exceed a threshold of 0.35g for a minimum of 1 second
- accel_event_cat
character, severity categorization of acceleration event into low (0.35-0.44g), medium (0.45-0.59g), and high (>0.6g)
- gyro_x
numeric, angular rotation rate about the right-to-left axis (in degrees/sec)
- gyro_y
numeric, angular rotation rate about the forward-to-backward axis (in degrees/sec)
- gyro_z
numeric, angular rotation rate about the up-to-down axis (in degrees/sec)
- gyro_heading
numeric, calculated heading utilizing compass data and gyro data (in degrees with north at 0 degrees and increasing clockwise). Note that we use non-standard congruence classes for continuity of consecutive values. Due to errors in the raw gyro heading, we use the initial GPS heading value as the initial heading value and then subtract the cumulative sum of gyro_z for the subsequent observations to calculate gyro_heading.
- grav_x
numeric, lateral gravity (in g)
- grav_y
numeric, longitudinal gravity (in g)
- grav_z
numeric, gravity (up-down) (in g)
- roll
numeric, angle about the forward-to-backward axis. 0 = level, positive = tilted to the left (in degrees)
- pitch
numeric, angle about the left-to-right axis where 0 = level, positive = tilted downward (i.e., vehicle going downhill) (in degrees)
- engine_rpm
numeric, current engine revolutions per minute value
- engine_throttle
numeric, engine throttle as a percentage (0-100%)
- cumulative_drive_dist_mi
numeric, the cumulative distance driven in miles at each observation
- gps_minute
factor, the minute component of the timestamp for each observation (00 to 59)
Raw heading measurements:
- gps_heading_raw
numeric, raw GPS heading without continuity correction (in degrees)
- gyro_heading_raw
numeric, raw gyro heading without continuity correction (in degrees)