In this tutorial, we explore ggplot2 package.
The first steps are to install and call the package.
install.packages("ggplot2")
library(ggplot2)
ggplot(data, aes() )+ geom
Use the head() function to investogate the variables
and data types.
Which variables are numerical?
Which variables are categorical?
Use levels() function for categorical
variables.
Use summary() function for numerical
variables.
Use geom_bar() geometry to develop a bar plot for
the variable Suburb, Rooms,
Bedroom, Bathroom and
Carpark.
Interpret the results.
We avoid using geom_bar() for continious numerical
variables. Use geom_bar() for developing a bar plot for the
variable Price. Explain what went wrong.
Use geom_bar() and develop a bar plot for the
variable Suburb.
color and fill arguments for the
variable Type.position = "dodge" argument to develop a clustered
bar plot.Type across
the Suburb.fill and color arguments
and instead use facet_wrap(~Type).facet_wrap or color is a
better presentation.Use geom_histogram() function to develop a histogram
for the variables Price, Distance,
Landsize and BuildingArea.
Use bins arguments to change the number of
bins.
Use binwidth arguments to change width of
bins.
Use geom_histogram() function to develop a histogram
for the variables Price.
color and fill arguments for the
variable Suburb.facet_wrap() function for the variable
Suburb.geom_histogram() function to develop a histogram
for the variables Price. Use facet_wrap()
function for the variable Suburb. Use the
color and fill arguments for the variable
Type.Use geom_point() function to develop a scatter
plot.Consider y=Price and continious
variables of x=Distance, x=Landsize,
x=BuildingArea.
Use geom_point() function to develop a scatter
plot.Consider y=Price and descrite
variables of x=Rooms, x=Bedroom,
x=Bathroom, and x=Carpark.
Use geom_point() function to develop a scatter
plot.Consider y=Price and x=Landsize.
shape argument for creating different
shapes.size argument to change the size.position = "jitter" argument to include a
random variation in the data location.facet_wrap(~Suburb) to partition the data by
Suburb.geom_smooth() to develop a trendline