0

I get very different results, the code should be equivalent?

qplot(x = price, data = diamonds) + facet_wrap(~cut)

vs

ggplot(aes(x = diamonds$price), data = diamonds) + geom_histogram()  + facet_wrap(~cut)

1 Answer 1

2

try this instead

ggplot(aes(x = price), data = diamonds) + geom_histogram()  + facet_wrap(~cut)
Sign up to request clarification or add additional context in comments.

1 Comment

Exactly, $ has no place inside aes since ggplot2 does non-standard evaluation. It looks for variables inside the declared data.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.