Share
Visualizing data with ggplot2 in R
Question
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Have you heard about the most popular package for visualizing data in a stunning way in R, i.e ggplot2 (grammar of graphics) ? How to deal with it ?
Answer ( 1 )
Ggplot2 is the powerful plotting package that makes simple to create complex charts in a beautifully stunning ways. Its a grammar of graphics having visual properties to represent the data. Begin your plot with ggplot().
“How to install it in R? ”
install.packages(“ggplot2”)
library(ggplot2)
General expression:
ggplot(data = ) +
(mapping = aes())
For example: For the mpg data set:
ggplot(data = mpg) +
geom_smooth(mapping = aes(x = displ, y = hwy, linetype = drv))
Components of Graphs are:
1.Data
2.Aesthetic mapping
3.Geom (geometric object)
4.Stat (statistical transformation)
5.Position adjustment
For making use of the components in the correct way ,one can go through the cheatsheet attached in the answer.
Attachment