View source: R/graph_edit_distance.R
| create.distance.plot | R Documentation |
Creates a plot of edit distances with optional smoothing or regression results.
create.distance.plot(
x,
y,
smooth = TRUE,
smooth.method = "loess",
mark.x = NULL,
xlab = "Number of Nearest Neighbors (k)",
ylab = "Edit Distance",
main = NULL,
width = 6,
height = 6,
...
)
x |
Numeric vector of x-axis values (e.g., k values). |
y |
Numeric vector of y-axis values (e.g., edit distances). |
smooth |
Logical indicating whether to add a smoothing line (default: TRUE). |
smooth.method |
Character string specifying the smoothing method. Options include "loess" (default), "lm", "glm", "gam". |
mark.x |
Optional numeric value(s) to mark with vertical lines. |
xlab |
Character string for x-axis label (default: "Number of Nearest Neighbors (k)"). |
ylab |
Character string for y-axis label (default: "Edit Distance"). |
main |
Character string for plot title (default: NULL, no title). |
width |
Numeric value for plot width in inches (default: 6). |
height |
Numeric value for plot height in inches (default: 6). |
... |
Additional arguments passed to |
The function creates a scatter plot with optional smoothing line. If
mark.x is provided, vertical dashed lines are added at those x-values.
Returns NULL invisibly after drawing the plot.
k.vals <- c(5, 10, 15, 20)
distances <- c(2.2, 1.4, 1.1, 1.3)
create.distance.plot(k.vals, distances, smooth = FALSE)
min.k <- k.vals[which.min(distances)]
create.distance.plot(k.vals, distances, mark.x = min.k,
smooth = FALSE,
main = "Edit Distance vs k")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.