You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are two issues with the plotting of points and centroids in the current version of candisc. The default behavior fails to plot one group of points when three groups are present:
Note that the virginica points are not plotted (the 3rd factor level and the last group in the data frame. Note also that the centroid color for both virginica and setosa is the same (red). If we specify the symbols and colors, that seems to fix the problem:
plot(iris.can, pch=1:3, col=1:3)
Now all seems fine, but this is only because the data frame is sorted by the factor levels.
This time versicolor is not plotted. It appears last in the randomized data order (in the 4th row). Also virginica and setosa still use the same color (red). Now we try specifying the symbol and color as previously:
plot(iris.rnd.can, pch=1:3, col=1:3)
Note that the colors of the centroids and the data points do not match. The centroid colors are in factor order, but the point symbol/colors are in order of appearance in the data.
The text was updated successfully, but these errors were encountered:
There are two issues with the plotting of points and centroids in the current version of candisc. The default behavior fails to plot one group of points when three groups are present:
Original data
library(candisc)
data(iris)
iris.mod <- lm(cbind(Petal.Length, Sepal.Length, Petal.Width, Sepal.Width) ~ Species, data=iris)
iris.can <- candisc(iris.mod, data=iris)
plot(iris.can)
Note that the virginica points are not plotted (the 3rd factor level and the last group in the data frame. Note also that the centroid color for both virginica and setosa is the same (red). If we specify the symbols and colors, that seems to fix the problem:
plot(iris.can, pch=1:3, col=1:3)
Now all seems fine, but this is only because the data frame is sorted by the factor levels.
Randomize the order of the data,
set.seed(42)
iris.rnd <- iris[sample(rownames(iris)), ]
head(iris.rnd, 4)
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
138 6.4 3.1 5.5 1.8 virginica
140 6.9 3.1 5.4 2.1 virginica
43 4.4 3.2 1.3 0.2 setosa
123 7.7 2.8 6.7 2.0 virginica
iris.rnd.mod <- lm(cbind(Petal.Length, Sepal.Length, Petal.Width, Sepal.Width) ~ Species, data=iris.rnd)
iris.rnd.can <- candisc(iris.rnd.mod, data=iris.rnd)
plot(iris.rnd.can)
This time versicolor is not plotted. It appears last in the randomized data order (in the 4th row). Also virginica and setosa still use the same color (red). Now we try specifying the symbol and color as previously:
plot(iris.rnd.can, pch=1:3, col=1:3)
Note that the colors of the centroids and the data points do not match. The centroid colors are in factor order, but the point symbol/colors are in order of appearance in the data.
The text was updated successfully, but these errors were encountered: