Put simply, I want to color outliers, but only if they belong to specific category, i.e. I want
boxplot(mydata[,2:3], col=c("chartreuse","gold"), outcol="red")
but red only for those elements for which mydata[,1] is M .
Put simply, I want to color outliers, but only if they belong to specific category, i.e. I want
boxplot(mydata[,2:3], col=c("chartreuse","gold"), outcol="red")
but red only for those elements for which mydata[,1] is M .
Copyright © 2021 Jogjafile Inc.
It appears that
outcolonly specifies one color per variable (box). However, you can usepointsto overplot individual points any way that you want. You need to figure out the relevant x and y coordinates to use for plotting. When you make a boxplot with a statement likeboxplot(mydata[,2:3])the first variable (column 2) is plotted at x=1 and the second variable (column 3) is plotted at x=2. By capturing the return value ofboxplotyou can figure out the y values. Since you do not provide any data, I will illustrate with randomly generated data.