nlevels(object)中的错误:参数"对象"缺少,没有默认值

时间:2017-09-17 20:10:03

标签: r

我试图更改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"))

关于如何让眼睛颜色变为识别颜色的任何想法?我错过了什么?

1 个答案:

答案 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"))