我试图更改R中HairEyeColor包中的默认颜色值,并在运行时继续在nlevels中获取错误:
library(ggplot2)
hec = data.frame(HairEyeColor)
ggplot(hec,aes(Hair, Freq))+
geom_point(aes(colour = Eye))+
scale_color_manual(values = C("brown" = "chocolate4", "blue" = "blue3",
"hazel" = "#663", "green" = "darkgreen"))
关于如何让眼睛颜色变为识别颜色的任何想法?我错过了什么?
答案 0 :(得分:0)
这是一种语法错误,是由于您错误地将value
向量的大小写为大写字母引起的。应为:values = c()
我已在以下更正它:
library(ggplot2)
hec = data.frame(HairEyeColor)
ggplot(hec,aes(Hair, Freq))+
geom_point(aes(colour = Eye))+
scale_color_manual(values = c("brown" = "chocolate4", "blue"= "blue3", "hazel" = "#663", "green" = "darkgreen"))