I'm trying to change the default color values in the HairEyeColor package in R and keep getting the error in nlevels when I run this:
我正在尝试更改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"))
Any ideas on how I can get the eye colors to change to the identified colors? What am I missing?
关于如何让眼睛颜色改变为识别颜色的任何想法?我错过了什么?
1 个解决方案
#1
0
This is a syntax error is caused by you miss-typing the value
vector with a capital C. Should be: values = c()
这是一个语法错误,是由于您错误地输入了带有大写字母C的值向量。应该是:values = c()
I have corrected it below:
我在下面更正了它:
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
This is a syntax error is caused by you miss-typing the value
vector with a capital C. Should be: values = c()
这是一个语法错误,是由于您错误地输入了带有大写字母C的值向量。应该是:values = c()
I have corrected it below:
我在下面更正了它:
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"))