In this module, we reviewed three types of visualization in R: basic visualization without any package, lettuce and ggplot2. Choose any data set for your visualization from Vincent Arel Bundock dataset list: https://vincentarelbundock.github.io/Rdatasets/datasets.html (Links to an external site.) Using this data, generate three types of visualization on the data set you have chosen. In your blog, discuss and present your three visualizations you will create and express your opinion on these three different types of graphics output.
I will be using the Salaries Package that I have found from the link provided in the assignment
I will be using this data to visualize a scatter plot concept and will be creating 3 scatter plots from 3 different packages which will be from the Base, ggplot and lattice package.
Before I start, I will load the required packages and the Salaries dataset
library(ggplot2)
library(lattice)
data(Salaries, package="carData")
#Scatter with Base R
x <- Salaries$yrs.since.phd
y <- Salaries$salary
z <- Salaries$rank
plot(x, y, main = "Academic Salary by years since phd via base R",
xlab = "Years Since Phd", ylab = "Salary Growth",
col = z)
# plot experience vs. salary in GGplot package
ggplot(Salaries,
aes(x = yrs.since.phd,
y = salary,
color = rank)) +
geom_point() +
labs(title = "Academic salary by years since degree")
#GGplot displays the label of the rank of
x <- Salaries$yrs.since.phd
y <- Salaries$salary
z <- Salaries$rank
xyplot(y ~ x, main = "Academic Salary by years since phd via lattice package"
,xlab = "Years Since Phd", ylab = "Salary Growth",
col = z)
#Does Not display the labels of the rank of professors
To conclude as seen from the visualizations. The ggplot package produces the best results out of the 3. Personally the worst results I felt like I got from procuding the graph would be from the use of the Lattice package. The difference from the lattice package compared to the base R would be that the graph from the lattice produced these points from the right side and top of it and as for the base it produced a cleaner version of it and they also produced the same color pattern when I use rank variable as the color, another small detail would be that the ggplot actually display the labels of the color of rank on the side of the graph not like the other 2 that doesn’t. But overall if it came to visualization I see that ggplot would be the best option, due to it displaying the best visualization.