我有一个Dataset,想要使用stat_smooth()显示一个数字。
首先,我可以显示Age vs Scored_Probabilities(男性)数字,如下所示:
names(dataset2) <- sub(pattern=' ', replacement='.', x=names(dataset2))
dataSet3 <- subset(dataset2,Gender== 'male')
#patterns VS Age
d <- ggplot(dataSet3, aes(y=Scored.Probabilities, x=jitter(as.numeric(Age)), colour=factor(patterns)))
d + stat_smooth() +scale_colour_brewer(palette="Set3")
但是当男性变为女性时,会出现错误:
#Female
dataset4 <- subset(dataset2,Gender== 'female')
#patterns VS Age
d <- ggplot(dataset4, aes(y=Scored.Probabilities, x=jitter(as.numeric(Age)), colour=factor(patterns)))
d + stat_smooth()+scale_colour_brewer(palette="Set3")
Error in smooth.construct.cr.smooth.spec(object, data, knots) :
x has insufficient unique values to support 10 knots: reduce k.
第二,&#34; Set3&#34;颜色似乎不足以绘制。哪种颜色可以解决它?