This report is intended to create a number of visualizations for the variables contained in the dataset “Attitude”. Specifically, this report includes matrices of histograms, boxplots and scatterplots for all the variables. This report was created on Wed Apr 10 22:07:52 2019.

The first visualization contains a matrix of histograms for the Attitude variables

#Produce a matrix of histograms
library(reshape2)
## Warning: package 'reshape2' was built under R version 3.5.3
library(ggplot2)
attitudeM <- melt(attitude)
## No id variables; using all as measure variables
g <- ggplot(attitudeM,aes(x=value))
g <- g + geom_histogram()
g <- g + facet_wrap(~variable) + ggtitle("Matrix of Histograms for the Attitude variables") +
  theme(plot.title = element_text(hjust = 0.5))
g
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

Next, a matrix of scatterplots between all the variables of the Attitude dataset.

#Create a matrix of scatterplots between all variables
pairs(~rating+complaints+privileges+learning+raises+critical+advance, data = attitude, 
      main = "Matrix of Scatterplots for all the Attitude variables")

The visualization below shows the the boxplots for each of the Attitude variables

#Create a boxplot for each variable
boxplot(attitude, main="Boxplots for the Attitude variables")

Given that I wasn’t 100% sure if my use of the matrices of plots was the intended, I also prepared individual plots relying on the coding provided in “Lecture 5 - Statistical Graphs”.

First, I created a boxplot for each individual variable

#Create a boxplot for each individual variable and combine them
fig1 <- par(mfrow = c(4, 2)) 
boxplot(attitude$rating, main = "Rating Boxplot")
boxplot(attitude$complaints, main = "Complaints Boxplot")
boxplot(attitude$privileges, main = "Privileges Boxplot")
boxplot(attitude$learning, main = "Learning Boxplot")
boxplot(attitude$raises, main = "Raises Boxplot")
boxplot(attitude$critical, main = "Critical Boxplot")
boxplot(attitude$advance, main = "Advance Boxplot")

Next, an individual histogram for each variable, including the labels on top of the bins.

#Create an histogram for each individual variable and combine them
par(mfrow = c(4, 2))
hist(attitude$rating, main = "Rating Histogram", labels = TRUE)
hist(attitude$complaints, main = "Complaints Histogram", labels = TRUE)
hist(attitude$privileges, main = "Privileges Histogram", labels = TRUE)
hist(attitude$learning, main = "Learning Histogram", labels = TRUE)
hist(attitude$raises, main = "Raises Histogram", labels = TRUE)
hist(attitude$critical, main = "Critical Histogram", labels = TRUE)
hist(attitude$advance, main = "Advance Histogram", labels = TRUE)

Last, I created a few scatterplots showing the relationships between a few pairs of variables

#A few examples of individual scatterplots and combine them
par(mfrow = c(2, 2))
plot(attitude$rating, attitude$complaints, type = "p", xlab = "Rating", ylab = "Complaints",
     main="Scatterplot of Rating vs Complaints")
plot(attitude$privileges, attitude$learning, type = "p", xlab = "Privileges", ylab = "Learning",
     main="Scatterplot of Privileges vs Learning")
plot(attitude$raises, attitude$critical, type = "p", xlab = "Raises", ylab = "Critical",
     main="Scatterplot of Raises vs Critical")
plot(attitude$advance, attitude$critical, type = "p", xlab = "Advance", ylab = "Critical",
     main="Scatterplot of Advance vs Critical")

This report has been published in RPubs and can be found under the following link: http://rpubs.com/borjaureta/484826