ggplot error Don't know how to automatically pick scale for object of type data.frame

cat88 Source

suppose the data frame is like this

df <- data.frame(age = c("20", "21", "22", "20", "21","22"), 
   female = c("female", "female", "female", "male", "male", "male"), 
   income =c("1000", "2000","3000", "1500", "2400", "5600"))

I want to get two lines from ggplot that show me the comparison of income between female and male. I ran the following code:

 p <- ggplot(df, aes(x=age, y=income, group = female)) +
                         geom_line(color ="blue") 

I got the following error: Don't know how to automatically pick scale for object of type data.frame. Defaulting to continuous

Error: Aesthetics must either be length one, or the same length as the dataProblems:female

Anyone has idea what's wrong?

rggplot2

Answers

comments powered by Disqus