Assignment #9: Visualization in R – Base Graphics, Lattice, and ggplot2

 For this assignment, I used the airquality dataset from the datasets package in R. I chose this dataset because it includes several quantitative variables such as Ozone, Temperature, and Wind, along with a grouping variable, Month, which made it a good fit for comparing different graphing systems in R. After loading the dataset, I removed missing values and converted the Month variable into a factor so it would work better in grouped and faceted plots.

Using base R, I created a scatter plot of Temperature versus Ozone and a histogram of Wind. Base R was straightforward and easy to use for simple plots, but it required more manual setup for labels and appearance. With lattice, I created a conditioned scatter plot of Ozone versus Temperature by Month and a boxplot of Wind by Month. Lattice was useful for grouped displays and small multiples, and it made conditioning by category very simple. Finally, with ggplot2, I created a scatter plot with a regression line and a faceted histogram by Month. ggplot2 felt the most flexible and polished because it uses layering, which makes it easier to build complex visuals step by step.

The syntax and workflow were noticeably different across the three systems. Base R uses separate functions and direct variable references, which works well for quick graphs but can feel limited for more advanced visualizations. Lattice is especially strong for multivariate and conditioned plots, but the syntax can feel less intuitive at first. ggplot2 provided the most control and produced the most publication-quality output with relatively little code once the structure was set up. The biggest challenge when switching between systems was remembering that each one handles grouping and customization differently. Overall, ggplot2 was my favorite because it was easier to create clean, layered, and professional-looking graphics.

Comments

Popular posts from this blog

ABC vs. CBS: Comparing Fictional Presidential Poll Data in R

Assignment #10: Building Your Own R Package

Module # 4 Programming structure assignment