Use the attitude dataset to produce at least one scatter plot, histogram, and box-and-whisker plot for each variable.
The dataset attitude is from a survey of the clerical employees of a large financial organization, the data are aggregated from the questionnaires of the approximately 35 employees for each of 30 (randomly selected) departments. The numbers give the percent proportion of favorable responses to seven questions in each department.
attitude
## rating complaints privileges learning raises critical advance
## 1 43 51 30 39 61 92 45
## 2 63 64 51 54 63 73 47
## 3 71 70 68 69 76 86 48
## 4 61 63 45 47 54 84 35
## 5 81 78 56 66 71 83 47
## 6 43 55 49 44 54 49 34
## 7 58 67 42 56 66 68 35
## 8 71 75 50 55 70 66 41
## 9 72 82 72 67 71 83 31
## 10 67 61 45 47 62 80 41
## 11 64 53 53 58 58 67 34
## 12 67 60 47 39 59 74 41
## 13 69 62 57 42 55 63 25
## 14 68 83 83 45 59 77 35
## 15 77 77 54 72 79 77 46
## 16 81 90 50 72 60 54 36
## 17 74 85 64 69 79 79 63
## 18 65 60 65 75 55 80 60
## 19 65 70 46 57 75 85 46
## 20 50 58 68 54 64 78 52
## 21 50 40 33 34 43 64 33
## 22 64 61 52 62 66 80 41
## 23 53 66 52 50 63 80 37
## 24 40 37 42 58 50 57 49
## 25 63 54 42 48 66 75 33
## 26 66 77 66 63 88 76 72
## 27 78 75 58 74 80 78 49
## 28 48 57 44 45 51 83 38
## 29 85 85 71 71 77 74 55
## 30 82 82 39 59 64 78 39
dim(attitude)
## [1] 30 7
names(attitude)
## [1] "rating" "complaints" "privileges" "learning" "raises"
## [6] "critical" "advance"
# scatter plot for rating
plot(attitude$rating, ylab = "Rating by Department", xlab = "Percentage of Favorable Response", frame.plot = FALSE, xlim = c(min=0,max=40), ylim = c(min=0,max=100), col = "#A871F7", main = "Percentage of Response on Rating by Department Employees")
# histogram for rating
hist(attitude$rating, xlab = "Rating by Department", col = "#A871F7", main = "Rating Frequency of Org by Department Employees", border = "#FFFFFF", labels = TRUE, ylim = c(min=0,max=10),xlim = c(min=0,max=100), breaks = 10 )
# box-and-whisker plot for rating
boxplot(attitude$rating, xlab = "Rating by Department" , main = "Box-and-whisker plot of Ratings by Dept", frame.plot = TRUE, ylim = c(min=0,max=100), col ="#A871F7", ylab = "Percentage of Favorable Responses" )
#--------------------------------------------------------
# scatter plot for complaints
plot(attitude$complaints, ylab = "Complaints by Department", xlab = "Percentage of Favorable Response", frame.plot = FALSE, xlim = c(min=0,max=40), ylim = c(min=0,max=100), col = "#A871F7", main = "Percentage of Response on Complaints by Department Employees")
# histogram for complaints
hist(attitude$complaints, xlab = "Complaints by Department", col = "#A871F7", main = "Complaints Frequency of Org by Department Employees", border = "#FFFFFF", labels = TRUE, ylim = c(min=0,max=10),xlim = c(min=0,max=100), breaks = 10 )
# box-and-whisker plot for complaints
boxplot(attitude$complaints, xlab = "Complaints by Department" , main = "Box-and-whisker plot of Complaints by Dept", frame.plot = TRUE, ylim = c(min=0,max=100), col ="#A871F7", ylab = "Percentage of Favorable Responses" )
#--------------------------------------------------------
# scatter plot for privileges
plot(attitude$privileges, ylab = "Privileges by Department", xlab = "Percentage of Favorable Response", frame.plot = FALSE, xlim = c(min=0,max=40), ylim = c(min=0,max=100), col = "#A871F7", main = "Percentage of Response on Privileges by Department Employees")
# histogram for privileges
hist(attitude$privileges, xlab = "Privileges by Department", col = "#A871F7", main = "Privileges Frequency of Org by Department Employees", border = "#FFFFFF", labels = TRUE, ylim = c(min=0,max=10),xlim = c(min=0,max=100), breaks = 10 )
# box-and-whisker plot for privileges
boxplot(attitude$privileges, xlab = "Privileges by Department" , main = "Box-and-whisker plot of Privileges by Dept", frame.plot = TRUE, ylim = c(min=0,max=100), col ="#A871F7", ylab = "Percentage of Favorable Responses" )
#--------------------------------------------------------
# scatter plot for learning
plot(attitude$learning, ylab = "Learning by Department", xlab = "Percentage of Favorable Response", frame.plot = FALSE, xlim = c(min=0,max=40), ylim = c(min=0,max=100), col = "#A871F7", main = "Percentage of Response on Learning by Department Employees")
# histogram for learning
hist(attitude$learning, xlab = "Learning by Department", col = "#A871F7", main = "Learning Frequency of Org by Department Employees", border = "#FFFFFF", labels = TRUE, ylim = c(min=0,max=10),xlim = c(min=0,max=100), breaks = 10 )
# box-and-whisker plot for learning
boxplot(attitude$learning, xlab = "Learning by Department" , main = "Box-and-whisker plot of Learning by Dept", frame.plot = TRUE, ylim = c(min=0,max=100), col ="#A871F7", ylab = "Percentage of Favorable Responses" )
#--------------------------------------------------------
# scatter plot for raises
plot(attitude$raises, ylab = "Raises by Department", xlab = "Percentage of Favorable Response", frame.plot = FALSE, xlim = c(min=0,max=40), ylim = c(min=0,max=100), col = "#A871F7", main = "Percentage of Response on Raises by Department Employees")
# histogram for raises
hist(attitude$raises, xlab = "Raises by Department", col = "#A871F7", main = "Raises Frequency of Org by Department Employees", border = "#FFFFFF", labels = TRUE, ylim = c(min=0,max=10),xlim = c(min=0,max=100), breaks = 10 )
# box-and-whisker plot for raises
boxplot(attitude$raises, xlab = "Raises by Department" , main = "Box-and-whisker plot of Raises by Dept", frame.plot = TRUE, ylim = c(min=0,max=100), col ="#A871F7", ylab = "Percentage of Favorable Responses" )
#--------------------------------------------------------
# scatter plot for critical
plot(attitude$critical, ylab = "Critical by Department", xlab = "Percentage of Favorable Response", frame.plot = FALSE, xlim = c(min=0,max=40), ylim = c(min=0,max=100), col = "#A871F7", main = "Percentage of Response on Critical by Department Employees")
# histogram for critical
hist(attitude$critical, xlab = "Critical by Department", col = "#A871F7", main = "Critical Frequency of Org by Department Employees", border = "#FFFFFF", labels = TRUE, ylim = c(min=0,max=15),xlim = c(min=0,max=100), breaks = 10 )
# box-and-whisker plot for critical
boxplot(attitude$critical, xlab = "Critical by Department" , main = "Box-and-whisker plot of Critical by Dept", frame.plot = TRUE, ylim = c(min=0,max=100), col ="#A871F7", ylab = "Percentage of Favorable Responses" )
#--------------------------------------------------------
# scatter plot for advance
plot(attitude$advance, ylab = "Advance by Department", xlab = "Percentage of Favorable Response", frame.plot = FALSE, xlim = c(min=0,max=40), ylim = c(min=0,max=100), col = "#A871F7", main = "Percentage of Response on Advance by Department Employees")
# histogram for advance
hist(attitude$advance, xlab = "Advance by Department", col = "#A871F7", main = "Advance Frequency of Org by Department Employees", border = "#FFFFFF", labels = TRUE, ylim = c(min=0,max=10),xlim = c(min=0,max=100), breaks = 10 )
# box-and-whisker plot for advance
boxplot(attitude$advance, xlab = "Advance by Department" , main = "Box-and-whisker plot of Advance by Dept", frame.plot = TRUE, ylim = c(min=0,max=100), col ="#A871F7", ylab = "Percentage of Favorable Responses" )
# matrix scatter plot
plot(attitude, main = "Matrix Visualization of Scatter plot on attitude dataset", col = "#A871F7", xlim = c(min=0, max = 100), ylim = c(min = 0, max = 100))
# matrix histogram
library(psych)
multi.hist(attitude, density = TRUE, freq = TRUE, xlim = c(min=0,max=100), bcol="#A871F7")
# matrix box-and-whisker plot
# method I
boxplot(attitude, col = "#A871F7", las = 3, main = "Matrix box-and-whisker plot on attitude dataset ")
# method II
library(ggplot2)
##
## Attaching package: 'ggplot2'
## The following objects are masked from 'package:psych':
##
## %+%, alpha
ggplot(stack(attitude), aes(x = ind, y = values, fill = ind)) + geom_boxplot(alpha = 0.5) + theme_bw() + ggtitle("Matrix box-and-whisker plot on attitude dataset")