Skip to content

Commit

Permalink
Merge pull request #1587 from rstudio/nanoplot-gap-marker
Browse files Browse the repository at this point in the history
Add option to use `"marker"` option for missing values in `cols_nanoplot()`
  • Loading branch information
rich-iannone committed Feb 25, 2024
2 parents 753d7ca + b5e81aa commit 5bf9636
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
14 changes: 8 additions & 6 deletions R/modify_columns.R
Original file line number Diff line number Diff line change
Expand Up @@ -2234,13 +2234,15 @@ cols_add <- function(
#'
#' @param missing_vals *Treatment of missing values*
#'
#' `singl-kw:[gap|zero|remove]` // *default:* `"gap"`
#' `singl-kw:[gap|marker|zero|remove]` // *default:* `"gap"`
#'
#' If missing values are encountered within the input data, there are three
#' strategies available for their handling: (1) `"gap"` will display data gaps
#' at the sites of missing data, where data lines will have discontinuities;
#' (2) `"zero"` will replace `NA` values with zero values; and (3) `"remove"`
#' will remove any incoming `NA` values.
#' strategies available for their handling: (1) `"gap"` will show data gaps
#' at the sites of missing data, where data lines will have discontinuities
#' and bar plots will have missing bars; (2) `"marker"` will behave like
#' `"gap"` but show prominent visual marks at the missing data locations; (3)
#' `"zero"` will replace `NA` values with zero values; and (4) `"remove"` will
#' remove any incoming `NA` values.
#'
#' @param autoscale *Automatically set x- and y-axis scale limits based on data*
#'
Expand Down Expand Up @@ -2742,7 +2744,7 @@ cols_nanoplot <- function(
rows = everything(),
plot_type = c("line", "bar", "boxplot"),
plot_height = "2em",
missing_vals = c("gap", "zero", "remove"),
missing_vals = c("gap", "marker", "zero", "remove"),
autoscale = FALSE,
autohide = TRUE,
columns_x_vals = NULL,
Expand Down
8 changes: 4 additions & 4 deletions R/utils_plots.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ generate_nanoplot <- function(
x_vals = NULL,
expand_x = NULL,
expand_y = NULL,
missing_vals = c("gap", "zero", "remove"),
missing_vals = c("gap", "marker", "zero", "remove"),
all_y_vals = NULL,
all_single_y_vals = NULL,
plot_type = c("line", "bar"),
Expand Down Expand Up @@ -895,7 +895,7 @@ generate_nanoplot <- function(

if (is.na(data_y_points[i])) {

if (missing_vals == "gap") {
if (missing_vals == "marker") {

# Create a symbol that should denote that a
# missing value is present
Expand All @@ -905,7 +905,7 @@ generate_nanoplot <- function(
"cx=\"", data_x_points[i], "\" ",
"cy=\"", safe_y_d + (data_y_height / 2), "\" ",
"r=\"", data_point_radius_i + (data_point_radius_i / 2), "\" ",
"stroke=\"red\" ",
"stroke=\"", "red", "\" ",
"stroke-width=\"", data_point_stroke_width_i, "\" ",
"fill=\"white\" ",
">",
Expand Down Expand Up @@ -956,7 +956,7 @@ generate_nanoplot <- function(

if (is.na(data_y_points[i])) {

if (missing_vals == "gap") {
if (missing_vals == "marker") {

# Create a symbol that should denote that a
# missing value is present
Expand Down
14 changes: 8 additions & 6 deletions man/cols_nanoplot.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 comments on commit 5bf9636

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.