|
19 | 19 | #' @seealso
|
20 | 20 | #' [geom_polygon()]: Filled paths (polygons);
|
21 | 21 | #' [geom_segment()]: Line segments
|
| 22 | +#' @section Missing value handling: |
| 23 | +#' `geom_path()`, `geom_line()`, and `geom_step` handle `NA` as follows: |
| 24 | +#' |
| 25 | +#' * If an `NA` occurs in the middle of a line, it breaks the line. No warning |
| 26 | +#' is shown, regardless of whether `na.rm` is `TRUE` or `FALSE`. |
| 27 | +#' * If an `NA` occurs at the start or the end of the line and `na.rm` is `FALSE` |
| 28 | +#' (default), the `NA` is removed with a warning. |
| 29 | +#' * If an `NA` occurs at the start or the end of the line and `na.rm` is `TRUE`, |
| 30 | +#' the `NA` is removed silently, without warning. |
22 | 31 | #' @export
|
23 | 32 | #' @examples
|
24 | 33 | #' # geom_line() is suitable for time series
|
|
57 | 66 | #' base + geom_path(size = 10, lineend = "round")
|
58 | 67 | #' base + geom_path(size = 10, linejoin = "mitre", lineend = "butt")
|
59 | 68 | #'
|
60 |
| -#' # NAs break the line. Use na.rm = T to suppress the warning message |
61 |
| -#' df <- data.frame( |
62 |
| -#' x = 1:5, |
63 |
| -#' y1 = c(1, 2, 3, 4, NA), |
64 |
| -#' y2 = c(NA, 2, 3, 4, 5), |
65 |
| -#' y3 = c(1, 2, NA, 4, 5) |
66 |
| -#' ) |
67 |
| -#' ggplot(df, aes(x, y1)) + geom_point() + geom_line() |
68 |
| -#' ggplot(df, aes(x, y2)) + geom_point() + geom_line() |
69 |
| -#' ggplot(df, aes(x, y3)) + geom_point() + geom_line() |
| 69 | +#' # You can use NAs to break the line. |
| 70 | +#' df <- data.frame(x = 1:5, y = c(1, 2, NA, 4, 5)) |
| 71 | +#' ggplot(df, aes(x, y)) + geom_point() + geom_line() |
70 | 72 | #'
|
71 | 73 | #' \donttest{
|
72 | 74 | #' # Setting line type vs colour/size
|
|
0 commit comments