I was exploring the capabilities of the smartEDA package and stuck with a challenge. The target column "US" has 2 categories - "Yes" and "No". The output (below) shows the same colour for 2 categories compared to having 2 different colours.
For instance, "Yes" - blue / "No" - red
Here's the sample code.
#install.packages("ISLR")
library("ISLR")
#install.packages("SmartEDA")
library("SmartEDA")
plot31 <- ExpNumViz(Carseats,target="US",nlim=4,scatter=TRUE,fname=NULL)
plot31[[1]]
I explored the arguments from the ExpNumViz
function by adding the col
parameter (documentation: define the fill colour for box plot. Number of color should be equal to number of categories in target variable)
plot31 <- ExpNumViz(col = 2, Carseats,target="US",nlim=4,scatter=TRUE,fname=NULL) #assuming 2 categories
However, I received the following error
Error in `f()`:
! Insufficient values in manual scale. 2 needed but only 1 provided.
Run `rlang::last_error()` to see where the error occurred.
Any workarounds are greatly appreciated.
CodePudding user response:
You should specify the color names in col parameter. The number of color names elements must match the number of categories ploted.
plot31 <- ExpNumViz(Carseats,
target="US",
nlim=4,
scatter=TRUE,
fname=NULL,
col = c("Red", "Blue"))
plot31[[1]]