sinhrks / ggfortify

Define fortify and autoplot functions to allow ggplot2 to handle some popular R packages.
Other
527 stars 65 forks source link

Strange Handling of Colouring By Variable in Current Environment #135

Open DarioS opened 7 years ago

DarioS commented 7 years ago

The legend is missing.

species <- as.numeric(factor(iris[, "Species"]))
autoplot(prcomp(iris[, 1:4]), colour = species, environment = environment())
Warning message:
In if (value %in% columns) { :
  the condition has length > 1 and only the first element will be used

Picking a column from the data frame works without a problem.

autoplot(prcomp(iris[, 1:4]), data = iris, colour = "Species") # Legend shown.
sinhrks commented 7 years ago

related to #120. Currently , colour must be a single string of column name to specify color. Will consider a fix when I have a time.