-
Notifications
You must be signed in to change notification settings - Fork 101
Open
Description
Hi,
I really love this package and have never had an issue until today. Due diligence: I have re-installed the package, restarted R, searched stack exchange, dummy coded a new variable, tried palette, tried subsetting so only the variable that won't habillage is included etc.
I ran prcomp on a dataframe and want to use fviz_pca_ind to see where the individuals land. I have 10 categorical variables that I can habillage by with no problem. When I try to habillage by "mulch" there is no color grouping. Mulch shows up as a factor with three levels, n values are missing. I don't know what to do.
#The data
NYbeet <- (see attached data
NYbeet <- NYbeet %>%
mutate_at(vars(year, crop, trt, system, till, tarp, mulch, block, plot), factor) %>% drop_na()
#the PCA
pcaNYbeet <- prcomp((NYbeet[,10:20]), scale = TRUE)
#Visualize the Eigenvalues
fviz_eig(pcaNYbeet)
#Plot by variables
fviz_pca_var(pcaNYbeet, repel = TRUE)
summary(pcaNYbeet)
NYbeetvar <- get_pca_var(pcaNYbeet)
NYbeetvarred <- get_pca_var(pcaNYbeetred)
NYbeetvar$coord
NYbeetvar$cos2
NYbeetvar$contrib
NYbeetind <- get_pca_ind(pcaNYbeet)
NYbeetindred <- get_pca_ind(pcaNYbeetred)
NYbeetind$coord
NYbeetind$cos2
NYbeetind$contrib
#Plot by individuals, by habillage type.
fviz_pca_ind(pcaNYbeet, repel = TRUE, label ="none", geom = "point", pointsize=3)
fviz_pca_ind(pcaNYbeet, repel = TRUE, label ="none", habillage = NYbeet$year, geom = "point", pointsize=3)
fviz_pca_ind(pcaNYbeet, repel = TRUE, label ="none", habillage = NYbeet$system, geom = "point", pointsize=3)
fviz_pca_ind(pcaNYbeet, repel = TRUE, label ="none", habillage = NYbeet$till, geom = "point", pointsize=3)
fviz_pca_ind(pcaNYbeet, repel = TRUE, label ="none", habillage = NYbeet$tarp, geom = "point", pointsize=3)
fviz_pca_ind(pcaNYbeet, repel = TRUE, label ="mulch", habillage = NYbeet$mulch, geom = "point", pointsize=3)
#Everything works except the last one
Metadata
Metadata
Assignees
Labels
No labels