Enable negative or logical index in columns= argument to ggpairs().
krivit opened this issue · 0 comments
krivit commented
Minimal example
library(GGally)
data(iris)
ggpairs(iris)
# Colour-code by Species:
ggpairs(iris, aes(col=Species, fill=Species, alpha=I(0.3))) # Species column and row redundant.
ggpairs(iris, aes(col=Species, fill=Species, alpha=I(0.3)), columns=1:4, legend=1) # Works
ggpairs(iris, aes(col=Species, fill=Species, alpha=I(0.3)), columns=-5, legend=1) # Error
#> Error in fix_column_values(data, columns, columnLabels, "columns", "columnLabels"): Make sure your numeric 'columns' values are positive.
#> columns = c(-5)
Discussion
Since negative and logical indices are standard in R, it would be helpful if one could use them to specify columns to exclude. This could be fixed by mapping it through a vector, e.g., columns <- seq_len(ncol(data))[columns]
, around line 99 below:
Lines 85 to 112 in 53c1f65
I would be happy to submit a PR.