-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Labels
GraphicsIssues related to graphicsIssues related to graphicsRIssue should require knowledge of R onlyIssue should require knowledge of R onlyneeds patchImplement the agreed fix and prepare a patch for reviewImplement the agreed fix and prepare a patch for review
Description
Background
Currently boxplot() will create a boxplot even when there are fewer than 5 points, e.g.
set.seed(1)
x <- c(sample(1:10, 17, replace = TRUE), 50, 52)
g <- rep(1:2, c(4, 15))
x[g ==1]
#> [1] 9 4 7 1
bx <- boxplot(x ~ g)The boxplot for each group is based on the output from boxplot.stats(), which uses stats::fivenum() internally
boxplot.stats(x[g ==1])
#> $stats
#> [1] 1.0 2.5 5.5 8.0 9.0
#>
#> $n
#> [1] 4
#>
#> $conf
#> [1] 1.155 9.845
#>
#> $out
#> numeric(0)boxplot() returns these stats along with the group index for outliers and the name of each group:
bx
#> $stats
#> [,1] [,2]
#> [1,] 1.0 1.0
#> [2,] 2.5 4.0
#> [3,] 5.5 6.0
#> [4,] 8.0 9.5
#> [5,] 9.0 10.0
#>
#> $n
#> [1] 4 15
#>
#> $conf
#> [,1] [,2]
#> [1,] 1.155 3.756252
#> [2,] 9.845 8.243748
#>
#> $out
#> [1] 50 52
#>
#> $group
#> [1] 2 2
#>
#> $names
#> [1] "1" "2"Created on 2025-11-17 with reprex v2.1.1
Task
-
Update
boxplot.default()to plot points rather than a boxplot when there are fewer than five points (in a group). Specifically- Return all
NAfor thestatsandconfelements - Return the data points as outliers in
outinstead, also updatinggroupto identify those "outliers" as belonging to the respective group - For groups with
NAstats, plot the outliers as points instead of a boxplot
The code is in src/library/graphics/R/boxplot.R
- Return all
-
Update the help file to say that the data values are treated as outliers when there are fewer than 5 values.
-
If time, run the tests for a package that depends on
boxplot(), e.g. {ggplot2} , to check the impact.
Metadata
Metadata
Assignees
Labels
GraphicsIssues related to graphicsIssues related to graphicsRIssue should require knowledge of R onlyIssue should require knowledge of R onlyneeds patchImplement the agreed fix and prepare a patch for reviewImplement the agreed fix and prepare a patch for review
Type
Projects
Status
In Progress
