What is the difference between the qplot() function and the ggplot() function from the ggplot2 package in R?


I read that we can use the qplot() and the ggplot() functions to get the same plots in R.
For example->


ggplot(diamonds, aes(clarity,fill=cut)) +geom_bar()

Both of the above commands give the exact same plot->

What exactly is the difference between these functions?


more complex plot requires ggplot(), if both qplot and ggplot are available, the criterion depends on whether data is stored in data.frame or separate variables.

And it sounds good to always use ggplot(), because using qplot only save your type but lose many functionalities.

1 Like