WhatsApp Chat Sentiment Analysis in R

Plot Discrete Single Variable Using ggplot2

Step 1: Import Data using package ISLR

>install.packages("ISLR")
>library(ISLR)
>data("Wage")

Step 2: Install and Load

>install.packages("ggplot2")
>library(ggplot2)

Step 3: Explore the data

>summary(Wage)

Output:

>names(Wage)

Output:

Step 4: Plot Discrete variable (wage)

>ggplot(Wage, aes(wage))+geom_bar(stat = "bin")

Output:

Add Colour

>ggplot(Wage, aes(wage))+geom_bar(stat = "bin", fill = "dark blue")

Output:

Lable X and Y Axis

>ggplot(Wage, aes(wage))+geom_bar(stat = "bin", fill = "dark blue")+xlab("Wage of Employees")+ylab("Number of Employees")

Output: