0

I have a Dataset, and want to show a figure using stat_smooth().

First, I can show the Age vs Scored_Probabilities (male) figure, which looks like this:

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

Man

But when changing male to female, an error occurs:

#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.

Second, the "Set3" color seems not enough to plot. Which color set can solve it?

Jeffery Chen
  • 323
  • 2
  • 4
  • 13
  • 16 or more discrete colors can not be mapped/distinguished well by a human reader. Find a different approach to your plot. Also, have you considered following the advice in the error message and set a lower value of k? – Roland May 14 '15 at 09:44
  • It could work if I reduce my amount of dataset. But 'male' dataset is bigger than 'female', I don't know why – Jeffery Chen May 14 '15 at 10:09

0 Answers0